Bug 44573

Summary: Pattern stream has unbalanced q/Q operators (too many q's)
Product: cairo Reporter: Petr Dlouhý <petr.dlouhy>
Component: pdf backendAssignee: Adrian Johnson <ajohnson>
Status: RESOLVED WORKSFORME QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium    
Version: 1.10.2   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Petr Dlouhý 2012-01-08 05:31:36 UTC
When generating Mapnik vector map outputs with Cairo, and then converting the file to PostScript with pdf2ps, the convertor prints following message to output:

   **** Error reading a content stream. The page may be incomplete.
   **** Warning: Pattern stream has unbalanced q/Q operators (too many q's)

   **** This file had errors that were repaired or ignored.
   **** The file was produced by: 
   **** >>>> cairo 1.10.2 (http://cairographics.org) <<<<
   **** Please notify the author of the software that produced this
   **** file that it does not conform to Adobe's published PDF
   **** specification.
Comment 1 Petr Dlouhý 2012-01-08 05:37:06 UTC
The generated file can be downloaded from http://cozpserver2.jinonice.cuni.cz/~petr/download/MTB-vektor-export/Cairo-bug/BIG_export_A2.pdf
Comment 2 Petr Dlouhý 2012-01-09 05:10:54 UTC
Thank you for your quick answer, that explained lot of my problems.

That is not quite pleasant behavior, when using certain format for it's vector features.

Is there any debug mode in which the fact, that Cairo is going to fallback is printed out? Or even better - can be the fallback mode controlled from the code (ie. forbidden or detected)?
Comment 3 Adrian Johnson 2012-01-09 05:30:34 UTC
(In reply to comment #2)
> That is not quite pleasant behavior, when using certain format for it's vector
> features.

Cairo is designed to produce the same output across all surfaces. If an operation is not supported it is rasterized. I'm not sure that there is any sensible alternative. Do you think it should ignore unsupported drawing operations or convert them to something that is supported but looks obviously different?

> Is there any debug mode in which the fact, that Cairo is going to fallback is
> printed out? Or even better - can be the fallback mode controlled from the code
> (ie. forbidden or detected)?

You can grep the PostScript for the 'Fallback' comment. The only way to avoid fallback images is to restrict yourself to drawing operations that are natively supported by surface you are using.
Comment 4 Petr Dlouhý 2012-01-09 05:55:29 UTC
Sorry for responding to wrong bug in the first comment.

I have much control over the input stream as long as it is done by Mapnik.
It would be helpful if I could set fallback forbidden mode, in which the Cairo will throw exception when trying to paint unsupported feature.
Comment 5 Adrian Johnson 2015-10-18 05:06:44 UTC
There have been a lot of changes since 1.10.2 and there is no test case here for me to try. So I'm assuming it works now. Please reopen if it is still a problem.

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.