Last active
September 11, 2017 05:33
-
-
Save shanmdphd/5883f2009afb7a4c390afe01b54d868e to your computer and use it in GitHub Desktop.
Flatten PDFs with ghostscript (GS를 사용해서 PDF를 flattening할 수 있습니다. MacOS Sierra에서 테스트하였습니다.)
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
# http://zeroset.mnim.org/2015/01/07/flatten-pdfs-with-ghostscript/ | |
# https://unix.stackexchange.com/questions/162922/is-there-a-way-to-flatten-a-pdf-image-from-the-command-line | |
# There should be `flat` sub-directory. | |
for file in *.pdf; do | |
gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite \ | |
-sColorConversionStrategy=/LeaveColorUnchanged \ | |
-dAutoFilterColorImages=true \ | |
-dAutoFilterGrayImages=true \ | |
-dDownsampleMonoImages=true \ | |
-dDownsampleGrayImages=true \ | |
-dDownsampleColorImages=true \ | |
-sOutputFile="flat/flat-$file" "$file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment