Wednesday, January 21, 2009

How to make a PDF from a series of images

I was compiling a supplication extracted from a book of supplications. The problem at hand was to make a PDF out of various A4 images I had i.e. page01.xcf, page02.xcf, .., and so on. (XCF is a GIMP image)

A friend suggested ps2pdf, a command-line tool to convert from PostScript files to PDF.
Since GIMP can save to PS format, I saved all my images into PS format first.
However, the tool would accept only one ps file as input. So, I could get PDF file for each image, separately. Clearly this is not desired.

However, ps2pdf can read input from stdin by using -.
The solution was straightforward now:
$ cat page*.ps | ps2pdf - supplication.pdf

Works out of the box! (though takes some time).