1

I have an encrypted pdf, and I am aware of the password, and I would like to use the Ghostscript to make them unencrypted, so they don't require any password to be opened.

I tried using the following, But it seems I'm doing something wrong

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=OUTPUT.pdf -c .setpdfwrite -f -sUserPassword=mypassword encrypted.pdf

2 Answers2

3

If using a different tool like pdftk/qpdf first is an option, the answers to this question have a couple of methods, for example qpdf -password=mypassword -decrypt encrypted.pdf OUTPUT.pdf

1henno1
  • 51
3

If you have a pdf that is encrypted and you know the password you can decrypt the pdf as follows

gs -dNOPAUSE -dBATCH -q -sDEVICE=pdfwrite -sPDFPassword=password -sOutputFile=output2.pdf -f input.pdf

Now let me tell you about each option being used

  1. -sDEVICE: its a device, use man gs to learn more
  2. -dNOPAUSE: Disables the prompt and pause at the end of each page. This may be desirable for applications where another program is driving Ghostscript.
  3. -q: do things quietly, no logs on screen
  4. -sPDFPassword: Its the password
  5. -dBATCH: I think it is for quitting the gs

Like every Linux Program, the Documentation (man pages) is written very poorly and doesn't have a lot of information.