Skip to content

Instantly share code, notes, and snippets.

@skishida
Last active June 11, 2019 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skishida/ef5290527cf2637fa7402a98325aca87 to your computer and use it in GitHub Desktop.
Save skishida/ef5290527cf2637fa7402a98325aca87 to your computer and use it in GitHub Desktop.
decrypt edit-locked pdf and unlock view-locked pdf with ghost script
function decrypt-pdf() {
command ghostscript -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=${1%.*}-dec.pdf -c .setpdfwrite -f $1
}
function unlock-pdf() {
command ghostscript -q -dNOPAUSE -dBATCH -sPDFPassword=$2 -sDEVICE=pdfwrite -sOutputFile=${1%.*}-dec.pdf -c .setpdfwrite -f $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment