Convert png to pdf

Linux tip, Fedora tip / howto: convert multiple images to a PDF

back to notes and tips index

Let’s assume you have scanned 10 pages from a book to files page1.png, page2.png, …, page10.png. We’ll use ImageMagick’s convert for the conversion.

* to reduce the final filesize, you can first reduce the color map size of the files, for example:
convert page1.png -colors 32 page1b.png
(increase/decrease the number 32 depending on how many different colors you’d like to see in the final PDF)
* if you’re running tcsh as your shell, you can do all pages in one go by:
foreach f (1 2 3 4 5 6 7 8 9 10)
convert page$f.png -colors 32 page${f}b.png
* convert the resulting images into a single PDF:
convert page*b.png mydoc.pdf

If you get an incorrect page count (recently I saw this when converting two PNG files to a PDF, it gave me page count of 1), you can try the following:

* convert page*.png
* ps2pdf13
* if stuff from a scanned A4 page does not show up correctly, you can try:
ps2pdf13 -sPAPERSIZE=a4

(so you first convert to PostScript. ps2pdf13 is part of the ghostscript package)

all sourced from:

0 comments on “Convert png to pdfAdd yours →

Leave a Reply

Your email address will not be published. Required fields are marked *