Last active
November 6, 2015 09:12
-
-
Save garaemon/e7de9794a6c1a0e1147b to your computer and use it in GitHub Desktop.
compress pdf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COMP_COMMAND = "/default" | |
$(COMPRESSED_OUTPUT).pdf: $(OUTPUT).pdf | |
echo "Compressing pdf" | |
rm -f .pdfmarks | |
pdfinfo $(OUTPUT).pdf | sed -e 's/^ *//;s/ *$$//;s/ \{1,\}/ /g' -e 's/^/ \//' -e '/CreationDate/,$$d' -e 's/$$/)/' -e 's/: / (/' > .pdfmarks | |
sed -i '1s/^ /[/' .pdfmarks | |
sed -i '/:)\$$/d' .pdfmarks | |
echo " /DOCINFO pdfmark" >> .pdfmarks | |
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=${COMP_COMMAND} -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$(COMPRESSED_OUTPUT).pdf" "${OUTPUT}.pdf" .pdfmarks | |
rm .pdfmarks | |
notify-send "Compressed PDF" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment