I have a PDF, made with Inkscape, that uses transparent colors. This image shall be used in a LaTeX document.

While preserving the transparency is nice for editing, it can be a problem for printing. Printing usually involves PDF to PS conversion. Since Postscript does not support transparency, this requires either

  • flatting, i.e. creating a vector graphic that works without transparency

or

  • rastering, i.e. rendering a bitmap image.

When a PDF document containing such a figure is printed (or converted to PS) using Evince (or Cairo or Ghostscript), the whole page gets rendered as a bitmap, rendering fonts ugly (different from other pages). (Adobe Acrobat handles such PDFs well.)

Unfortunately, converting the PDF figures to EPS (before including them with LaTeX) doesn't help much, because both pdftops and pdf2ps (again, Cairo or Ghostscript) rasterize the image, i.e. render a bitmap (saved as EPS). (This is slightly better, because it doesn't affect the whole page, but I'd still prefer a vector graphics.)

How can I flatten transparency with Inkscape or other software on Linux?


Solution 1:

One way around bad rasterization is to manually convert your PDF document to postscript because when you invoke CUPS through evince or whatever gui, it will be converted anyways.

You can try pdftops -r 1200 document.pdf to increase the resolution from the low default of 300, and then print the resulting postscript. However, with the printers at work this did not yield a significant improvement. Regular text on pages with and without transparent images still looked different -- blurry vs. clear.

So I ended up using Acrobat Professional (on a windows machine) to flatten the transparent images used in my latex document, which gave optimal results. Check that Transparency Flattener Preset is at [High Resolution] in the advanced print setup. My colleague mentioned that one could perhaps FTP a pdf file directly to a modern laserjet network printer, bypassing the postscript conversion. I have not tried this.

Would be great to have linux-only solution to this issue.

Solution 2:

I had the same problem and this is my solution (for future reference):

I tried a lot of things, and so far the best working solution that I found on the internet was rendering the PDF completely as an image with pdf2ps and ps2pdf13, but the result wasn't satisfactory for me, because all vector shapes were lost. I wanted to render only the critical parts, but retain the vector graphics.

What did the trick for me was to isolate all critical parts in inkscape and putting them on a separate layer (in my images this was all the shadows). I made only this layer (and the background layer) visible and exported it to PNG, effectively rendering all transparency effects, but only them. I imported it back and used it in a new layer. After flipping all layer visibilities (transparency layer: off, all others: on), the exported PDF worked perfectly with LaTeX and was printable without rendering the whole page as image.

TL;DR:

  1. Isolate all problematic transparencies to one layer (transparency masks, shadows, etc.)
  2. Make only the problematic layer & background visible
  3. Export to PNG
  4. Import the just created PNG and use as background
  5. Make all layers visible except the problematic layer
  6. Export to PDF
  7. Smile :)