Skip to content

Instantly share code, notes, and snippets.

@grimmo
Last active September 17, 2019 09:13
Show Gist options
  • Save grimmo/e9656d13a1ede5f39a456b2c76b75080 to your computer and use it in GitHub Desktop.
Save grimmo/e9656d13a1ede5f39a456b2c76b75080 to your computer and use it in GitHub Desktop.
Split PDF every nth page and convert output to PDF/A
#!/bin/bash
COUNTER=1
NUMBEROFPAGES=<LAST_PAGENUMBER_IN_INPUT_PDF>
while [ $COUNTER -lt $NUMBEROFPAGES ]; do
pdftk input.pdf cat $COUNTER-$((COUNTER+1)) output OUTPUT${COUNTER}.pdf
gs -dPDFA -dBATCH -dNOPAUSE -sProcessColorModel=DeviceCMYK -sDEVICE=pdfwrite -sPDFACompatibilityPolicy=1 -sOutputFile=OUTPUT${COUNTER}_A.pdf OUTPUT${COUNTER}.pdf
let COUNTER=COUNTER+2
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment