Created
August 19, 2024 12:39
-
-
Save knee-cola/d2075a3d0ab3fece618de23de7250c37 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# | |
# Extracts a range of pages from the given multi-page PDF document into a new PDF documents | |
# | |
# pdfsplit [input.pdf] [first_page] [last_page] [output.pdf] | |
# | |
# Example: pdfsplit big_file.pdf 10 20 pages_ten_to_twenty.pdf | |
# | |
# written by: Westley Weimer, Wed Mar 19 17:58:09 EDT 2008 | |
# | |
# The trick: ghostscript (gs) will do PDF splitting for you, it's just not | |
# obvious and the required defines are not listed in the manual page. | |
if [ $# -lt 4 ] | |
then | |
echo "Usage: pdfsplit input.pdf first_page last_page output.pdf" | |
exit 1 | |
fi | |
gs -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$4" -dFirstPage=$2 -dLastPage=$3 -sDEVICE=pdfwrite "$1" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment