How to Create a PDF File with a Password?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
palpacino

How to Create a PDF File with a Password?

Post by palpacino »

Hello All,

First time posting (obviously) although I have been using ImageMagick for a few weeks now and have referenced this site several times in trying to get the hang of things.

I just created some functionality to convert (combine) several images as well as a PDF file into a PDF file containing all of the aforementioned images.

The command looks like this in its natural state:

Code: Select all

convert file1.pdf file2.tif output.pdf
Well, we now have some PDFs floating around with passwords, but the good news is I have a function to get passwords and, using this forum, I saw the command for reading the PDFs with passwords and it works fine:

Code: Select all

convert -authenticate PassWord file1.pdf file2.tif output.pdf
Awesome, right?

Well, now I am told that I need to have it creating the PDF files back with their original passwords. I've tried things like:
convert -authenticate PassWord file1.pdf file2.tif -authenticate PassWord output.pdf
...but cannot come up with anything. I've googled the heck out of it. The closest I think that I've come is the realization that ImageMagick uses GhostScript to render PDF files? (Correct me if I am wrong on that last statement, please :)). So then I googled the heck out of GhostScript and command line parameters for it as well to no avail.

Now I am looking at the possibility of having spent all sorts of time on this whole ImageMagick office-wide implementation and now we won't be able to use it without some secondary junk that adds PW protection to PDF files! ugh.

Can anyone be so kind as to tell me if this is even possible with ImageMagick? And, if so, what the command line for it is?

Thank you!
whoisgregg

Re: How to Create a PDF File with a Password?

Post by whoisgregg »

Well, unfortunately the most I can tell you is what I found in the documentation for the -authenticate option:
Enciphering images being written is not supported.
Sorry, if there is a way then the documentation hasn't been updated. :(
Post Reply