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.

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 · 617 weeks and 5 days ago
Any encrypted PDF's around to test with?
pykler · 616 weeks and 4 days ago
Can this metod crack PDF Example - Password protection in ? (128-bit key length encryption and requires a password to open it (you can open it using the password test))
adrruiz · 542 weeks and 5 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 · 486 weeks and 6 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 · 424 weeks and 2 days 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.

What's this? 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.


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: