Remove security limitations from PDF documents using ghostscript

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=OUTPUT.pdf -c .setpdfwrite -f INPUT.pdf
Remove security from PDF document using this very simple command on Linux and OSX. You need ghostscript for this baby to work.

45
2009-12-14 21:30:22

1 Alternatives + Submit Alt

What Others Think

This is just great, so I can finally remove wine and GetPDF Encryptor/Decryptor :-)
nickwe · 469 weeks and 2 days ago
Any encrypted PDF's around to test with?
pykler · 468 weeks and 1 day ago
Can this metod crack PDF Example - Password protection in http://www.novapdf.com/kb/pdf-example-files-created-with-with-novapdf-138.html ? (128-bit key length encryption and requires a password to open it (you can open it using the password test))
adrruiz · 394 weeks and 2 days ago
The script for Windows works like a charm. It deserves high votes. To make it easy to use, add the path to gswin32c in your autoexec.bat file. Include the path to the input and output files in the command string (easiest to put them in the root directory of one of your drives).
tongass · 338 weeks and 3 days ago
Hi, thanks for this great script! It is so convenient to put this to batch that goes through multiple subfolder. But now I have a question. I have a huge number of files where not all of them are password protected. Converting them with this script will increase the file size and is not recommended. How can I make a script that first checks the PDF for security and if needed then applies GS?
proguru · 276 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

Considering A New Car?

You should consider a Tesla. Get 6 Months Free Supercharging.

Free Supercharging

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: