Specifying Passwords when Loading from a Stream

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
charlesd
Posts: 22
Joined: Thu Oct 20 2005
Location: Orem, Utah
Contact:

Specifying Passwords when Loading from a Stream

Post by charlesd »

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
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

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
Post Reply