I don’t know if it was possible back in 2008, but nowadays you can simply use the convert command provided by imagemagick!
convert image1.jpg image2.jpg output.pdf
Normally, when I need to create a PDF, I can print to the PDF printer included with KDE. However, on my suse box, this only seems to work out of the box with KDE apps. Also, since I need to combine multiple images into a pdf, it is a bit cumbersome to use a PDF printer here.
I didn’t find a one-step solution, so here is how I did it:
- convert each image to a pdf
- merge all pdfs into one pdf file
For the first step I used bmeps, a tool which I recently discovered by accident 🙂 It is strange, when searching for the tool, I didn’t find it. So that’s why I give it some extra promo on my blog. 😉 Bmeps is a cross platform tool (yes, I already once used it succesfully on windows!). It used to be a (E)PS tool, but since version 2.0 it also supports PDF output (up to PDF version 1.4). As input, it accepts JPEG, netpbm and PNG (and TIFF partially).
As Bmeps doesn’t seem too popular, I wasn’t too surprised to learn my distro doesn’t have any package for it, so I had to build it from source. Bmeps has a dependency on dklibs, a collection from the same author which also needs to be compiled. But it turned out to be a pleasant experience: all prerequisites were already satisfied on my computer (except netpbm, but I don’t need that) and I just had to run the familiar “configure make install” (once for dklibs and once for bmeps of course).
After that, converting an image to a pdf is as simple as:
bmeps image.jpg image.pdf
Now we have a bunch of pdf files, we still need to merge them. For that I chose the quite popular pdftk. It wasn’t installed by default, but there does exist a package in the suse main repositories, so that was easy. Now, to combine all pdfs into one:
pdftk input*.pdf cat output output.pdf
And that’s it!
PS: there used to be a tool png2pdf from the same author for people wanting to convert PNG files, but this has been superseded by bmeps.
2 thoughts on “Converting multiple images into a pdf on linux”