Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
1  
Interesting question. It would be very complex to flatten svg as every possible intersection of shapes would need to create a new opaque shape with composite fill. –  artfulrobot Oct 7 '12 at 16:26
    
@artfulrobot Exactly. The resulting vector graphics can in general become quite complex. However for a number of typically vector line art graphics, the result should still work well on a modern Postscript printer. –  Jan Oct 10 '12 at 13:11
    
The best method I've found is a tedious manual one, involving redrawing after an initial step: use inkscape to convert your pdf to an svg, open the svg in a good text-editor. Replace all occurrences of 'opacity:[0][0-9\.]' with 'opacity:1' (regex version) or find 'opacity:0.' and manually replace with opacity 1 (tedious version). Open the svg in inkscape and make it look nice again (the hard part), than back to pdf and on to eps. –  Chris H Jan 27 at 11:30

3 Answers 3

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.

share|improve this answer

One way is to make a white box in Inkscape the same size as your page and send it to the bottom layer. This will export your image with a white background instead of a transparent one.

share|improve this answer
    
The problem is not a transparent background and adding a white background does not solve it. The image question uses semi-transparent shapes ontop of other (opaque) shapes. SVG and PDF support this, but PS doesn't. –  Jan May 2 '12 at 11:11
pdftops -origpagesizes input.pdf output.ps

then

ps2pdf -r600x600 output.ps input-new.pdf
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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