Skip to content

Instantly share code, notes, and snippets.

Created Dec 8, 2011
What would you like to do?
src=`basename "$1" .pdf`
mkdir tmp
pdftk "${src}.pdf" dump_data output meta.txt
pdfimages "${src}.pdf" "tmp/${src}"
cd tmp
for f in *.ppm; do
tmp=`basename "$f" .ppm`
convert "${tmp}.ppm" -depth 4 -type Grayscale "${tmp}.png"
sam2p -j:quiet "${tmp}.png" "${tmp}.pdf"
rm "${tmp}.ppm" "${tmp}.png"
cd ..
pdftk tmp/*.pdf cat output tmp.pdf
pdftk tmp.pdf update_info meta.txt output "${src}.out.pdf"
rm -rf tmp.pdf tmp meta.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment