Skip to content

Instantly share code, notes, and snippets.

@baisong
Created May 15, 2017 06:58
Show Gist options
  • Save baisong/41c82374a3b36c17b55d37fc1f5b40c7 to your computer and use it in GitHub Desktop.
Save baisong/41c82374a3b36c17b55d37fc1f5b40c7 to your computer and use it in GitHub Desktop.
#############################
#
# Usage:
# ./mergepdf Example
# >> Example.pdf
#
# Run inside a directory with PDFs named like page1.pdf page2.pdf...
#
#############################
FILENAME=$1
echo "Creating $(echo $FILENAME)_raw.pdf...";
pdftk *.pdf output `(echo $FILENAME)`_raw.pdf
echo "Reducing filesize..."
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages -dCompressFonts=true -r300 -sOutputFile=`(echo $FILENAME)`.pdf `(echo $FILENAME)`_raw.pdf
echo "Done!"
echo " "
echo $(pwd)/$(echo $FILENAME).pdf
echo " "
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment