- Convert multipage PDF into single page PNG files with GhostScript
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
convert "*.png" output.pdf
Tested with OS X 10.11 El Capitan, commands should work on most any OS that can run these programs