How to remove copy/paste and print restrictions from a PDF file

Unlock a PDF fileI recently downloaded a huge PDF and wanted to copy and paste a couple sentences of text from it to email to a friend.

Unfortunately, the author had enabled copy/paste and print restrictions which prevented me from copying the two sentences that I wanted to send.

Too lazy to retype the text, I searched for a fast and easy technical solution.

As an aside: I fully respect copyright protections, but I wasn’t plagiarizing, I just wanted to share a small section with a friend. Fair use at its finest. I searched around and found a pretty simple solution.

The Steps to Unlock a PDF File

  1. Download Ghostscript. I got the 64-bit windows version (gs916w64.exe) here. It’s open source and free for non-commercial use.
  2. Check the download in VirusTotal. You can’t be too safe. A recent analysis is here.
  3. Install Ghostscript. The default options are fine.
  4. Open a command prompt on your Windows machine.
  5. Navigate to the gs install folder. Nav further to the \bin directory within it. You should see the executable gswin64.exe there. Mine was installed here: C:\Program Files\gs\gs9.16\bin
  6. From there, run this command: gswin64.exe -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=C:\stripped.pdf C:\protected.pdf

As you can see, I’m assuming that your protected file is called “protected.pdf” and is at the root of your machine. The unprotected file will be called “stripped.pdf” and will also be at the root of your machine. You can now copy, paste and print at will.

With great power comes great responsibility. Please don’t abuse the author’s copyright.