Unlocking Secured Password Protected PDF Files

February 23rd, 2013

Out of all the possible file formats out there, translating a PDF document is usually the worst-case scenario. The only thing worse than a PDF, is a locked password-protected PDF with security settings that don’t allow you to even copy and paste text out of it. It’s very difficult to look up Japanese words if you can’t copy the text, and you definitely can’t make use of translation memory software if you have no access to the text. So here is a simple way to unlock those secured PDFs to get access to the text.

You Will Need

A Linux computer or VM with Ghostscript installed.

How to Unlock the Secured PDF with Ghostscript

We’re actually going to create a identical copy of the PDF that is unlocked. We’ll use Ghostscript to do this. Ghostscript is a PostScript and PDF language interpreter and previewer that is commonly found pre-installed on most major Linux distributions. If it isn’t already installed, it can be easily obtained using your distro’s package management tool.

Using Ghostscript on Linux, you can unlock a PDF with a single command:

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=OUTPUT.pdf -c 
.setpdfwrite -f INPUT.pdf

That’s a rather long series of parameters, so let’s break it down so you understand what is going on.

  • The gs command invokes Ghostscript.
  • The -q switch invokes quiet mode, which suppresses a lot of messages that you probably aren’t interested in.
  • The -dNOPAUSE switch enables no pause after each page.
  • The -dBATCH switch will exit after the last file completes.
  • The -sDEVICE=pdfwrite switch selects the device. In this case, we select the pdfwrite device to create a PDF. Ghostscript works with numerous devices for almost every possible format, including graphic formats such as jpeg, tiff, png, bmp, etc.
  • The -sOutputFile=OUTPUT.pdf switch selects the output file that we are creating. We read in a locked PDF, and we create a new, unlocked PDF file called OUTPUT.pdf in this case.
  • The .setpdfwrite operator automatically sets up parameters that are useful for creating PDFs using the pdfwrite output device.
  • Our locked PDF file we want to unlock is INPUT.pdf in this example.

Converting Multiple Files in Batch

Suppose you have an entire directory full of locked PDF files you want to unlock. Here is a quick little Bash script you can do on the Linux command line to unlock all the PDFs at once.

for x in *.pdf
   gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=converted_$x -c 
   .setpdfwrite -f $x;

In this script, all of the converted PDFs will be prefixed with converted_.

That’s all there is to it. If you have a Linux computer or virtual machine, it just takes one command to create an unlocked copy of the PDF.

4 Responses to “Unlocking Secured Password Protected PDF Files”

  1. Pavel says:

    Thanks! Very useful!

  2. Jimmy says:

    For me the hint to the -sPDFPassword=somepwd switch to enter the password was missing.

  3. t.co/sFqvP1wsH4 says:

    Try with PDFelement, Set restrictions for opening, copying, editing, and printing to make sure your PDF files are safe.

  4. Hamid says:


    I want a software to convert Japanese PDF files to word format.

    Best regards,

Leave a Reply