Bug 689819

Summary: PDF q and Q operators inside paths
Product: Ghostscript Reporter: Piotr Strzelczyk <piotr>
Component: PDF InterpreterAssignee: Alex Cherepanov <alex>
Status: NOTIFIED FIXED    
Severity: major    
Priority: P4    
Version: 8.62   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: Example PDF
Ghostscript interpretation of example
Adobe Reader screenshot of example

Description Piotr Strzelczyk 2008-05-05 02:59:11 UTC
According to PDF documentation, 'q [some code] Q' used 'inside' path shouldn't
change the current path (unlike in PostScript).
In Ghostscript this behaviour is defined in lib/pdf_ops.ps (/grestore_nopath).
But if you change CTM between 'q' & 'Q', you will get unexpected effect:
after the `Q' operator the applied transformation changes the existing path.

I uploaded short PDF (nearly minimal example) with such construction,
and the results of rendering it in Ghostscript and Acrobat Reader.
Comment 1 Piotr Strzelczyk 2008-05-05 03:00:16 UTC
Created attachment 3980 [details]
Example PDF
Comment 2 Piotr Strzelczyk 2008-05-05 03:01:53 UTC
Created attachment 3981 [details]
Ghostscript interpretation of example
Comment 3 Piotr Strzelczyk 2008-05-05 03:02:35 UTC
Created attachment 3982 [details]
Adobe Reader screenshot of example
Comment 4 Alex Cherepanov 2008-05-06 14:06:44 UTC
Fix and simplify implementation of operator Q. Collecting the path with
the current ctm and re-playing it with the restored ctm transforms the
path exactly as PDF needs.

The following patch is committed as a rev. 8707.
http://ghostscript.com/pipermail/gs-cvs/2008-May/008288.html

Current regression testing shows no differences.
The sample file from this bug will be added to the public test suite
by the next revision.