Created
April 24, 2012 21:39
-
-
Save rcmachado/2484098 to your computer and use it in GitHub Desktop.
Split (extract) pdf pages from larger document
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/bash | |
# Usage ./pdfsplitr.sh inputfile.pdf outputfile.pdf pagenumber | |
# Example: ./pdfsplitr.sh myfile.pdf myotherfile.pdf 2 | |
# http://viktorpetersson.com/2010/10/22/how-to-split-a-pdf-files-on-mac-and-linuxunix/ | |
GS=$(which gs) | |
# Make sure Ghostscript is installed | |
if [[ $GS = "" ]] | |
then | |
echo “Ghostscript is not installed” | |
exit | |
fi | |
if [[ "$4" = "" ]] | |
then | |
LASTPAGE=$3 | |
else | |
LASTPAGE=$4 | |
fi | |
# Run the actual conversion. | |
$GS -sDEVICE=pdfwrite -q -dNOPAUSE -dBATCH -sOutputFile=$2 -dFirstPage=$3 -dLastPage=$LASTPAGE $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment