Last active
April 3, 2016 23:21
-
-
Save christopher-baek/fdb085911c12e876a96d to your computer and use it in GitHub Desktop.
PDF CLI Manipulation Examples
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
# batch crop pdf | |
# - 72 points == 1 inch == 25.4 millimeters | |
# | |
# Example A4: | |
# 595 points width == 210 millimeters | |
# 842 points height == 297 millimeters | |
# | |
# Example: | |
# left edge: 24 points == 1/3 inch ~= 8.5 millimeters | |
# right edge: 36 points == 1/2 inch ~= 12.7 millimeters | |
# top edge: 48 points == 2/3 inch ~= 17.0 millimeters | |
# bottom edge: 72 points == 1 inch ~= 25.4 millimeters | |
gs -o cropped.pdf -sDEVICE=pdfwrite -c "[/CropBox [24 72 559 794] /PAGES pdfmark" -f uncropped-input.pdf | |
gs -o cropped.pdf -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=595 -dDEVICEHEIGHTPOINTS=842 -dFIXEDMEDIA -c "24 72 translate 0 0 535 722 rectclip" -f uncropped-input.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
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="${OUTPUT_FILE}" $@ |
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
gs -sDEVICE=pdfwrite -dSAFER -o "${INPUT_FILE%.pdf}.%03d.pdf" "${INPUT_FILE}" |
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
# rotate all pages clockwise | |
pdftk in.pdf cat 1-endE output out.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
# rotate page 1 by 90 degrees clockwise | |
pdftk in.pdf cat 1E output out.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment