Bug 48260 - PDF print output of Cairo has unneeded transparency with badly defined bounding boxes
Summary: PDF print output of Cairo has unneeded transparency with badly defined boundi...
Alias: None
Product: cairo
Classification: Unclassified
Component: pdf backend (show other bugs)
Version: 1.10.2
Hardware: All Linux (All)
: medium major
Assignee: Adrian Johnson
QA Contact: cairo-bugs mailing list
Depends on:
Reported: 2012-04-03 10:00 UTC by Till Kamppeter
Modified: 2013-09-16 09:49 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Description Till Kamppeter 2012-04-03 10:00:25 UTC
For printing on Dabian and Ubuntu GTK/GNOME-based applications (like evince) generate PDF with Cairo and send it to CUPS. CUPS calls Ghostscript to convert this PDF into the printer's native data format.

Problem is that the PDF generated by Cairo renders very slowly with Ghostscript in the printing-typical resolutions of 600dpi and more.

This is caused by pointless use of transparency also if only opaque objects are drawn and in addition, the bounding boxes of the transparency groups are always the entire page. Since Ghostscript has to allocate memory to hold the raster data for each transparency the overall memory consumption can get multiples of the memory needed for th final page's raster data, making the machine swapping to the death.

Can this be improved? PDF-based printing got standard now.

Sample bug reports:

https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/668800 (comment #36)
Comment 1 Adrian Johnson 2012-04-03 15:57:45 UTC
The page sized bounding boxes problem has been fixed in 1.12.0. The use of transparency groups for opaque objects is something that can be improved.
Comment 2 Till Kamppeter 2012-04-03 16:15:21 UTC
Can you give me a patch for 1.10.2 which I could apply to the Ubuntu Precise (12.04) package?
Comment 3 Adrian Johnson 2012-04-03 16:30:50 UTC
There are too many changes.
Comment 4 Till Kamppeter 2013-03-07 10:10:06 UTC
To make printing also working well on mobile and generally low-performance devices it gets very important to completely do away with transparency in PDF output, at least if the document does not actually contain any transparent graphical elements.

We should perhaps even make one output mode optimized for printing with no transparency at all. This would allow fast print rendering, especially also on mobile. Ghostscript developers suggest PDF/X-1 output here.

Another mode could use transparency only where it is actually needed, for getting small, efficient PDF files for archiving and web download.

We should raise priority for this as slow printing is a very common problem under Linux (and mostly caused by the transparency abuse in Cairo output) and Linux gets more and more used on mobile battery-driven devices.
Comment 5 Till Kamppeter 2013-03-25 10:48:17 UTC
More Ubuntu bug reports showing this problem:

Comment 6 Uli Schlachter 2013-08-21 13:01:13 UTC
If I understand this correctly, this was fixed with cairo 1.12. At least Adrian claims so and no one claimed anything else.
Comment 7 Adrian Johnson 2013-09-11 11:52:02 UTC
I've pushed out a fix to make transparency groups normal groups when the content is opaque.
Comment 8 Till Kamppeter 2013-09-16 06:11:23 UTC
Adrian, can you post the patch or tell which commit it is, so that I can apply it to the current Poppler in Ubuntu?
Comment 9 Uli Schlachter 2013-09-16 08:07:52 UTC
Apply to Poppler? This is a bug about cairo...?

The commit that Adrian meant is:

And the following two patches fix some problems with it:

No idea if this can be backported sanely to older cairo versions, good luck.
Comment 10 Adrian Johnson 2013-09-16 08:24:57 UTC
I have not tried it but I expect those three patches should apply to 1.12.4 or later as not much has changed since then.

I would also recommend applying this patch to improve printing performance:


This patch fixes the embedding of jpeg data in the pdf output. Without it the file size will be a lot larger.
Comment 11 Adrian Johnson 2013-09-16 09:25:33 UTC
> I have not tried it but I expect those three patches should apply to 1.12.4
> or later

That should be 1.12.14 or later.
Comment 12 Till Kamppeter 2013-09-16 09:49:15 UTC
Thank you very much, the patches apply perfectly on Ubuntu's Cairo package (1.12.16). I have applied them to the Ubuntu package now.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.