Open a PDF Page as stream with VB 6
-
- Posts: 22
- Joined: Thu Oct 03 2002
- Location: Germany
Open a PDF Page as stream with VB 6
Do you have any examples???
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
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
-
- Posts: 22
- Joined: Thu Oct 03 2002
- Location: Germany
-
- Posts: 22
- Joined: Thu Oct 03 2002
- Location: Germany
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
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