User Tools

Site Tools


cs:pdf_to_pictures

This is an old revision of the document!


Convert PDF to pictures

Seldom printers fail to print a PDF file, a possible solution is to convert the file to a sequence of pictures; basically this means to do the whole process that decides where the inks should go in your computer; before sending the result to the printer.

Ghostscript does most of the hard work creating the pictures, however it does not apply any kind of smoothing to the curves so when creating a picture in the printing resolution (usually 300 DPI) the result will be poor.

To workaround this problem we use a trick similar to videogames antialiasing. We create the picture 4 times larger and we resize it later to the correct size applying smoothing algorithms.

Finally we losslessy put all the pictures in a new PDF. The resulting PDF will have no text, no fonts or anything a part of pictures. So it loses much of its convenience and the resulting file will be much larger, however printers will not fail to print it.

Software used:

  • ghostscript
  • imagemagick convert
  • img2pdf

Step 1, create the large image files:

$ gs -sDEVICE=pngalpha -o output-%04d.png -r1200 input.pdf

Please note that 1200 is four times the wanted resolution, we want to print to 300DPI.

Step 2, resize the resulting pictures to have antialiasing and remove transparency information:

$ for f in output-*  ;do convert "$f" -background white -alpha remove -alpha off -resize '25%' s"$f"  ;done

Step 3, rebuild an easy to print PDF:

$ img2pdf --pagesize a4 --border 0 --output easy2print_output.pdf soutput-*png
cs/pdf_to_pictures.1549563687.txt.gz · Last modified: 2019/02/07 18:21 by paolo_bolzoni