Encrypting an existing PDF file

Project:PDF Include project
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi,
Good Afternoon.
I am trying to encrypt an existing PDF file using the below code that was part of the PDFInclude project i have downloaded from this site.

I assume, after the end of the program, the output file 'hello-encrypt.pdf' supposed to be encrypted. But the file can be opened without any password.

Can you please help me?

Also, Is there anyway we can open an encrypted PDF document using 4GL commands.

I greately appreciate anyhelp that you can provide.

Thanks,
Satish.

**************************
{ pdf_inc.i "NOT SUPER"}

RUN pdf_new IN h_PDFinc ("Spdf","D:\PROGRESS\WRK\PDFIncude\samples\persistent\hello-encrypt.pdf").
RUN pdf_new_page IN h_PDFinc ("Spdf").

RUN pdf_text IN h_PDFinc ("Spdf", "Hello World!").

RUN pdf_Encrypt IN h_PDFinc
("Spdf",
"gord1",
"gord",
"noprint",
40,
"COM",
TRUE).

RUN pdf_close IN h_PDFinc ("Spdf").
***********************************


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

#1

In this example the resulting pdf file *is* encrypted, but as no password has been defined, it opens without any.
If you want a password, use the userpassword and masterpassword parameters.


#2

Hello,

I tried using the same code as the poster above did but the file is not encrypting correctly. I'm using a 64-bit AIX box. Are there known issues with using a 64-bit OS? Is there a solution?

Thanks.


#3

Hi
Sorry for the late answer.
In fact I answered wrongly above.
This API is for encrypting using the PLOP product from PDFLib (http://www.pdflib.com/products/plop/).
IIRC the open source version is not in fact interfaced with plop, but with PSP, an older version of PLOP.
Is this what you want to do?
If you want to encrypt with the open source version, only RC4-40 will work. In this case, it is using a 32 bits dll, so yes, if your OpenEdge product is 64 bits you will have problems. Having the OS 64 bits is not a problem though. Double check which version of OpenEdge you are using.
The native PDFInclude encryption is done this way:

{ pdf_inc.i "THIS-PROCEDURE"}

DEFINE VARIABLE cEncryptAlgo  AS CHARACTER   INITIAL "AES" NO-UNDO. /* RC4 or AES */
DEFINE VARIABLE cEncryptKey   AS CHARACTER   INITIAL "128" NO-UNDO.

RUN pdf_new ("Spdf","samples/super/hello-enc.pdf").

RUN pdf_set_parameter ("Spdf","Encrypt","TRUE").
RUN pdf_set_parameter ("Spdf","MasterPassword","M4st3rPwd").
RUN pdf_set_parameter ("Spdf","UserPassword","myPassword").

RUN pdf_new_page("Spdf").

RUN pdf_text("Spdf", "Hello World!").

RUN pdf_close("Spdf").

This will result in an RC4-40 encrypted pdf.

Warning: RC4-128 is not working in the opensource version; it is partially implemented but buggy. Generated files cannot be decrypted. Even with the password. They are wrong.

Nevertheless, I can provide you with a version supporting RC4-128 & AES-128 (and not using any dll for the latter) - and with lots of new funcionalities and bug fixes, if you are interested, please contact me privately.


#4

Hello,

Thanks for your response. I am not interested in using PLOP, but rather the open source version. I am using 64-bit OpenEdge Release 11.5 on a 64-bit AIX machine. With that said, I still tried the RC4-40 code snippet you provided and I am getting the following warning message: Value 4571623760 does not fit in long DLL datatype. (13712). The PDF still gets created and I prompted for the password, but the password does not work. Also, I see in your example that you declared cEncryptAlgo and cEncryptKey, but did not use them. Was there a reason for adding those variables? I even tried RUN pdf_set_parameter ("Spdf","EncryptKey","40").

Is there a solution for 64-bit Progress? Also, what is the best way to contact you directly?

Thanks.


#5

I want to create encrypted (password protected) pdf files. We are using OpenEdge 11.2 (64 bit) on Red Hat Linux (also 64 bit), as well as Progress 9.1E (32 bit) on AIX (64 bit).
Can this be done currently using PDFInclude with either/both of our versions?

We have been using an old 2004 version of PDFInclude successfully but without encryption on both versions of Progress.

Thanks.