Link to home
Start Free TrialLog in
Avatar of justinY
justinY

asked on

put password to a pdf file in C++

Hi Experts,

I need to put a password to a pdf file. How can I do that?

Thanks
Avatar of zvytas
zvytas
Flag of United Kingdom of Great Britain and Northern Ireland image

The following is in C#, but converting should not be a problem:

http://stackoverflow.com/questions/370571/password-protected-pdf-using-c
Avatar of justinY
justinY

ASKER

Thanks zvytas. But I dont know C#. Can you give me C++ version?
Avatar of tampnic
PDF is a difficult format to manipulate programmatically!

I recently had an application which needed to print data from a database onto a PDF formatted certificate. I changed the PDF certificate into a PDF form. I used the FDF toolkit from adobe to create an FDF file with the field data. I then needed to merge the FDF data into the PDF form fields. (There are commercial C++ libraries available to do this, most quite expensive and most designed to work as a server process) Then I modified the "pdftk" source code (open source) to create a DLL to merge the FDF data into the PDF form and create a PDF file, which was not a trivial undertaking!

My recommendation to you would be to create a PDF form as a template with a field to hold your password string (requires a full copy of Acrobat, the reader can't do this). Then your code can write an FDF file using the Adobe FDF Toolkit headers and library. Adobe Reader can merge the form data into the PDF form if both files are available to the user.

The other option would be to use libharu to assemble the pdf file directly.

Cheers,
 Chris
ASKER CERTIFIED SOLUTION
Avatar of tampnic
tampnic
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of justinY

ASKER

good stuff.
Thank you so much