Convert images to PDF

Use 'convert' (an utility that belongs to the ImageMagik package) to convert a bunch of images into a single pdf file:

convert *png output.pdf


If you receive an 'Out of memory' message when running the above command, do the following:

  1. set the TMPDIR variable to a directory with enough space:
    export TMPDIR=/var/tmp
  2. run 'convert' with the 'cache' option:
    convert -cache 500 *png output.pdf (assigns 500 Mb to the pixel cache)

Merge several PDF files into a single file

Use the Ghoscript 'gs' command:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf 001.pdf 002.pdf 003.pdf