The documentation for the PDF Creator describes how to use an IStream interface to load pdf data directly from a stream. This is working great.
I can even tell if the pdf data is password protected by looking at the Protected flag of the PDFCreactiveX object. My question is, how can I specify a password to use when opening pdf data from a stream?
Thansk for you help,
Charles
Specifying Passwords when Loading from a Stream
Hello,
The situation you have described is accomplished by passing the correct passwords to the PDF Creator's Document object before opening the stream.
I have included below a vb 6.0 code snippet which illustrates this.
Hope this helps?
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 retrieve from database
strFilePath = "c:\temp\stream_emcrypt.pdf"
'Create a stream to load into Control
Set objStream = CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
'open encrypted document by setting the Document objects "Ownerpassword" and
'"Userpassword" properties
'Owner Password
PDF1.ObjectAttribute("Document", "Ownerpassword") = "my ownerpassword value"
'User Passwpord
PDF1.ObjectAttribute("Document", "Userpassword") = "my userpassword value"
'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
The situation you have described is accomplished by passing the correct passwords to the PDF Creator's Document object before opening the stream.
I have included below a vb 6.0 code snippet which illustrates this.
Hope this helps?
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 retrieve from database
strFilePath = "c:\temp\stream_emcrypt.pdf"
'Create a stream to load into Control
Set objStream = CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
'open encrypted document by setting the Document objects "Ownerpassword" and
'"Userpassword" properties
'Owner Password
PDF1.ObjectAttribute("Document", "Ownerpassword") = "my ownerpassword value"
'User Passwpord
PDF1.ObjectAttribute("Document", "Userpassword") = "my userpassword value"
'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