Monday, 25 January 2010

Combine multiple images or multiple single-page PDFs into a multipage PDF

This method requires installing a (great) image-manipulation package, and using the command line, but it's very simple - suitable for someone new to using a command line.

If you do a lot of work with images, or have to do a lot of repetitive work or batch processing, I really recommend looking into ImageMagick. You can do things like make thumbnails of a certain size out of a directory, with just a few words.

Get Imagemagick if you don't have it already.
Open a commmand prompt and install ImageMagick:
apt-get install imagemagick
Now to combine your images into a multi-page PDF:
Go to the directory where are your images are.
cd /home/computername/pics
Convert the JPG files to PDF:
convert *.jpg foo.pdf
It will create a multi-page PDF, named foo.pdf in the directory you're in. Just make up whatever name you like for "foo". The pages will be arranged by alphabetical order (the filename). This method will use ALL of the jpg's in the directory. If you aren't familiar with using wildcards (*, ?) or are unfamiliar with command line, I recommend making a directory that only has the files you want to use, and put it in your /home directory so it's easy to find. If you want to only include files that differ by a letter, you can use something like
convert sample?.jpg samplepkg.pdf
...which will only place files like sample1.jpg, sample2.jpg, sample3.jpg in the pdf.

I have noticed the file size gets pretty large using this method. There are probably some command line options to set to manipulate this. Something that does make it smaller is using a graphics program like Gimp, and using the "print" option to "print to" a pdf. Then you can use the command line to combine the single page pdf's into a multipage single pdf.
convert *.pdf multi.pdf
"*" means everything, so keep in mind it will use every pdf in that directory to make a new one... even if it's multipage!

7 comments:

ethnopunk said...

convert *.jpeg foo.pdf

Segmentation fault

boyoffeeling said...

Dude, this is great!

Anonymous said...

coool ... thanx

prichard said...

it is so easy to use and safe... compared to free software for windows, where we have to be careful of virus infection

Anonymous said...

this tip saved my bacon!

Idham said...

Working, thank you :)

buyi wen said...

You can try this free online pdf to image converter to convert pdf to multipage tiff.