Skip to content

Instantly share code, notes, and snippets.

@knugie
Last active May 25, 2022 19:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knugie/9c82d8e5ecc18cf942b1 to your computer and use it in GitHub Desktop.
Save knugie/9c82d8e5ecc18cf942b1 to your computer and use it in GitHub Desktop.
usefull pdftk commands
# merge all pdf files from a directory to a single pdf file
pdftk *.pdf cat output out.pdf
# reverse page order of a pdf file
PDFTK_PAGES=$(pdftk in.pdf dump_data | grep NumberOfPages | sed "s/^.*: //")
pdftk in.pdf cat $PDFTK_PAGES-1 output out.pdf
# Strip metadata in pdf
PDFTK_FILE=in.pdf
pdftk $PDFTK_FILE dump_data | sed -e 's/\(InfoValue:\)\s.*/\1\ /g' | pdftk $PDFTK_FILE update_info - output out.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment