Skip to content

Instantly share code, notes, and snippets.

@scriptsandthings
Forked from stevekm/pdf_conversions.md
Created June 27, 2022 10:35
Show Gist options
  • Save scriptsandthings/d58aba74a08d70acbbbbf7f81fb6c427 to your computer and use it in GitHub Desktop.
Save scriptsandthings/d58aba74a08d70acbbbbf7f81fb6c427 to your computer and use it in GitHub Desktop.
Commands to convert multi-page PDF to/from multiple PNG files with GhostScript & ImageMagick
  • Convert multipage PDF into single page PNG files with GhostScript

http://superuser.com/questions/350201/convert-many-images-to-one-pdf-on-mac/854606?noredirect=1#comment1639104_854606

gs -o /path/to/output_page_%03d.png -sDEVICE=png16m -r150 /path/to/input.pdf
  • Convert multiple single-page PDF files into one multi-page PDF file
FILES="$(find /path/to/dir/ -type f -name "*.pdf" | sort)"
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged_output.pdf $FILES
  • Convert multiple PNG files into single multi-page PDF with ImageMagick

http://stackoverflow.com/questions/11002982/converting-multi-page-pdfs-to-several-jpgs-using-imagemagick-and-or-ghostscript?rq=1

convert "*.png" output.pdf

Tested with OS X 10.11 El Capitan, commands should work on most any OS that can run these programs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment