10

We have a printer at our office that prints PDF files from a USB stick. It prints most files okay, but it has problems with some, especially ones generated with Latex. Some PDFs it simply refuses to print, some PDFs it prints with courier-type font, and some it prints fine except for equations.

I'm looking for a way to "distill" PDFs into a dead-sure format to print. Either by simplifying / normalizing the PDF to the point that any renderer will render it correctly, or by simply making each page a 600dpi raster image in the PDF. (I could split the PDF into individual raster images and combine them manually, but I want something scriptable.)

The output file size doesn't matter, as long as it's sure to print, has A4 paper size (or the original) and 300~600dpi resolution.

  • Maybe pdf2ps could help if the printer is supporting postscript. – frlan Aug 25 '14 at 7:53
  • It's supposed to be a PostScript printer, but that support is even worse than that of PDF (and it won't print PS from a USB stick). – Sampo Aug 25 '14 at 9:12
17

After unsuccessfully trying some options to render the fonts as outlines (including this question and pstoedit), I figured out a way to easily convert the PDF into rasterized form using ImageMagick:

convert -density 600 +antialias input.pdf output.pdf

This creates a PDF rendered at 600 dpi, with antialias turned off (unnecessary at that resolution).

The output files are huge (~30 MB for an 8-page document) and extremely slow to print, but should work as long as the printer has enough memory to render the content.

  • 1
    Yes! I used this to flatten the layers in my PDF to great success. +antialias wasn't necessary because we only had images (it made no difference) and I dropped the resolution to 150 as that seemed good enough for archiving without taking up so much space. Thanks! – mlissner Oct 15 '14 at 18:57
  • 2
    Note that convert does not preserve the contents of forms you might have filled out. (I wanted to rasterize a PDF in order to make sure that the form contents look the same everywhere, in particular that they will be displayed by every PDF viewer in the first place.) In order to preserve the form contents, use evince (or whatever application you used to fill out the form) to print the document "to a file" – this is another PDF where the form contents have actually become part of the regular text. Then you still might rasterize this new PDF, depending on your needs. – balu Apr 13 '17 at 9:42
  • Note that this turns antialiasing on (+antialias) rather than turning it off (-antialias). – xiii1408 Jun 19 '18 at 22:59
  • No, +antialias disables antialiasing: imagemagick.org/script/command-line-options.php?#antialias – Sampo Jun 20 '18 at 15:21
  • 1
    I needed to tweak imagemagick (stackoverflow.com/questions/42928765/…) in order to make this work. – SteveSong Jan 18 at 16:25
-1

Another alternative is to convert to images via something like

pdfimages

From man page, "Pdfimages saves images from a Portable Document Format (PDF) file as Portable Pixmap (PPM), Portable Bitmap (PBM), or JPEG files. Pdfimages reads the PDF file PDF-file, scans one or more pages, and writes one PPM, PBM, or JPEG file for each image, image-root-nnn.xxx, where nnn is the image number and xxx is the image type (.ppm, .pbm, .jpg)."

Then use pdftk to convert back to PDF https://www.pdflabs.com/docs/pdftk-cli-examples/

Finally, print this file. Obviously, the key question is how to script this.

You could automate this via an simple webpage of some sort for users. Finally, they print out the converted file and you should have a higher performance and working printout?

  • 3
    pdfimages extracts embedded raster images from PDF files, is does not rasterize the text or vector graphics. – Sampo Feb 25 '15 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.