19

I've purchased a pdf and want to highlight areas of it and add comments for my own personal reference.

I've look at its properties through Foxit Reader (running through wine), and, irritatingly, I'm not allowed to Modify the Document or Comment in the Document

The pdf is just a normal pdf is every other respect.

How can I unlock this pdf so I can modify it and add comments?

muru
  • 197,895
  • 55
  • 485
  • 740
Starkers
  • 3,079
  • So, this has been set so by the owner of the document. Ask the owner of the document for a non-protected version. If you don't have the rights to crack the document, and you do it nevertheless, make sure that you are not get caught… – Max Wyss Dec 13 '14 at 21:50
  • 1
    @MaxWyss Thankyou for your concern (really!) but I don't think highlighting the main themes of a novel is going to blow up into the crime of the century :P – Starkers Dec 13 '14 at 21:58

6 Answers6

20

If you're not averse to using the terminal, there's a package called qpdf that you can install. It's in the software center. To remove protections from your file you can use something like this:

qpdf --password=your_password --decrypt yourfile.pdf output.pdf

That should do the job. As a side note, another useful (also command line) tool to have for working with pdf files is pdftk.
Example from man pdftk:

pdftk secured.pdf input_pw foopass output unsecured.pdf

Hope that helps!

dr_agon
  • 113
Turbo
  • 316
4

On Ubuntu 18.04 neither of two commands worked! (I don't know why). I followed the instructions to install pdftk (since it's no included in the repositories). However I figured it out (I think) in a simple way...

  1. evince mydocument.pdf
  2. ctrl+p
  3. Print to File (choose a new file name (or overwriting))

That's it, I could highlight with Foxit Reader.

1

Install Ghostscript and then run:

gs -sPDFPassword="$PASS" -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%stdout% -c .setpdfwrite -f locked.pdf > unlocked.pdf
David Foerster
  • 36,264
  • 56
  • 94
  • 147
1

Use this zsh function:

pdf-unencrypt () {
    : "Usage: <file>
Uses ghostscript to rewrite the file without encryption."
    local in="$1"
    gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="${in:r}_unencrypted.pdf" -c .setpdfwrite -f "$in"
}

: is a no-operations function. $in:r gets the variable without its extension. You obviously need ghostscript installed.

HappyFace
  • 325
1

I modified HappyFace's answer to work for

  • newer ghostscript versions
  • a list of files
  • passwords :)

Simply execute the following code in your shell (for me it also worked in a default ubuntu bash) and afterwards decrypt all pdfs in the current folder by running pdf-unencrypt *.pdf.

pdf-unencrypt () {
    : "Usage: <file>
Uses ghostscript to rewrite the file without encryption."
    echo "please type in password: (hidden prompt)"
    read -s passvar
    for in in "$@"
    do
        echo "trying to unecrypt $in"
        gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPDFPassword="${passvar}" -sOutputFile="${in:r}_unencrypted.pdf" -f "$in"
    done
    unset passvar
}

and afterwards decrypt all pdfs in the current folder by running pdf-unencrypt *.pdf.

AS1
  • 111
0

Turbo's answer with qpdf was very helpful.

I just wanted to contribute a one-liner bash command for anyone looking; this will decrypt all the PDF files in the current folder with qpdf (assuming the files all have the same password):

for f in *.pdf; do qpdf --password=[your password] --decrypt $f --replace-input; done

Note that it decrypts the files in-place. To output as a new file, you would have to leave out --replace-input and maybe prepend the filename placeholder with a folder or some other distinguisher.