Open a PDF Page as stream with VB 6

The PDF Creator enables you to create secure PDF documents and to view, print and process existing PDF documents.
If you have any questions about the installation and usage of the PDF Creator please post them here.
Post Reply
Giuseppe Ferlisi
Posts: 22
Joined: Thu Oct 03 2002
Location: Germany

Open a PDF Page as stream with VB 6

Post by Giuseppe Ferlisi »

Do you have any examples???
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

Below is a vb 6.0 code snippet which illustrates how to Open a PDF document from a stream.

Hope this helps?

Private Sub cmdLoadFromStream_Click()
Dim pdfStream As IPersistStreamInit
PDF1.SetLicenseKey LicenseTo, ActivationCode

Const adTypeBinary = 1
Dim strFilePath As String
Dim objStream As Object
Dim objStream2 As Object

'get file or retreive from database
strFilePath = App.Path & "\image.pdf"

'Create a stream to load into Control
Set objStream = CreateObject("ADODB.Stream")


objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath


'PDF1 is name of PDF Creator control on form
Set pdfStream = PDF1.Object

'Load stream into control
pdfStream.Load objStream
objStream.Close


PDF1.Refresh

Set objStream = Nothing
Set pdfStream = Nothing


End Sub
Giuseppe Ferlisi
Posts: 22
Joined: Thu Oct 03 2002
Location: Germany

Post by Giuseppe Ferlisi »

Hi,

thx for the code. We like to use the Object ACPDFCREACTIVEX.PDFCreactiveX instead the control. Do you have any example?

Giuseppe
Giuseppe Ferlisi
Posts: 22
Joined: Thu Oct 03 2002
Location: Germany

Post by Giuseppe Ferlisi »

We have the PDF page already as a string. Is there also a sample?

Giuseppe
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

Using ACPDFCREACTIVEX.PDFCreactiveX is very similar to what I originally posted. I have modified the code snippet slightly.


Private Sub cmdLoadFromObject_Click()
Dim PDF As Object
Set PDF = CreateObject("PDFCreactiveX.PDFCreactiveX")

Dim pdfStream As IPersistStreamInit
PDF.SetLicenseKey LicenseTo, ActivationCode

Const adTypeBinary = 1
Dim strFilePath As String
Dim objStream As Object
Dim objStream2 As Object

'get file or retreive from database
strFilePath = App.Path & "\image.pdf"

'Create a stream to load into Control
Set objStream = CreateObject("ADODB.Stream")


objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath


'PDF is name of Object
Set pdfStream = PDF


'Load stream into control
pdfStream.Load objStream
objStream.Close


PDF.Save App.Path & "\amyuni.PDF", 1

Set objStream = Nothing
Set pdfStream = Nothing
Set PDF = Nothing

End Sub

Hope this helps?
Jose
Post Reply