[Solved] 128 bit PDF encrypting

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
DanielBordeleau
Posts: 21
Joined: Tue Apr 29 2003
Location: Montreal, Quebec

[Solved] 128 bit PDF encrypting

Post by DanielBordeleau » Tue Apr 29 2003

Hi,
I'm trying to use the PDF Converter 2.1 to encrypt a document in 128 bit. And I just can't find the way to do it... I can't understand the link between the "Document.encrypt" method and the "FileNameOptions" property.

Please Help me! A code example would be really appreciated.

Many thanks.

Daniel

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Wed Apr 30 2003

Hello,

Here is a VB sample on generating an encrypted pdf file using 128 bits encryption:
Const NoPrompt As Long = 1
Const UseFileName As Long = 2
Const EncryptDocument128 = &H40000000

Private Sub cmdEncryptEmail_Click()
On Error GoTo printer_error
Set PDF = New CDIntfEx.CDIntfEx
PDF.DriverInit "Amyuni Document Converter"

PDF.DefaultDirectory = "c:\temp"
PDF.DefaultFileName = "c:\temp\sample.pdf"

'encryption
PDF.OwnerPassword = "owner"
PDF.UserPassword = "user"
PDF.Permissions = -64

PDF.FileNameOptionsEx = NoPrompt + UseFileName + EncryptDocument128

PDF.SetDefaultPrinter
PDF.EnablePrinter "License to", "xxxxxxx"

'print stuff ......

Exit Sub

printer_error:
MsgBox "Printer not found"
End Sub
I will move this thread to the VB forum as It can help VB Developers too.

Have a nice day !

DanielBordeleau
Posts: 21
Joined: Tue Apr 29 2003
Location: Montreal, Quebec

Post by DanielBordeleau » Wed Apr 30 2003

Thanks for that; It helped... But isn't there a way to encrypt in 128 bit using an already existing PDF?

Thanks

Daniel

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Thu May 01 2003

Unfotunately, there is not currently a way to encrypt in 128 bit using an already existing pdf file. Maybe this will be added in future versions.

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Fri May 02 2003

Hello Daniel,

I guess I replied too quickly.

You can encrypt a pdf file that is already generated by the PDF Converter using the DLL interface of CDIntf.

A new function is added to CDintf, it is EncryptPDFDocument128(). Here is its declaration in VB:

Declare Function EncryptPDFDocument128 Lib "CDIntf210" (ByVal FileName As String, ByVal Owner As String, ByVal User As String, ByVal Permissions As Long) As Long


Hope this helps.

Post Reply