Skip to content

Instantly share code, notes, and snippets.

@hannic
Last active December 9, 2018 20:29
Show Gist options
  • Save hannic/5349184 to your computer and use it in GitHub Desktop.
Save hannic/5349184 to your computer and use it in GitHub Desktop.
how to print password-protected pdf files with terminal (mac) #pdf #gs

How to unlock a protectd PDF

You have to get Ghostscript installed first. Run the script, that's it.

#!/bin/sh
# First, type the ghostscript line, second in GS env quit to generate the pdf 
# gs -sOutputFile=Document-unlocked.pdf -sDEVICE=pdfwrite -dNOPAUSE -dbatch -q Document-locked.pdf
# GS>quit()
# then unlocked doc gets generated
gs -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf $*
echo "Patched file is named output.pdf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment