diff options
author | Alex Cherepanov <alex.cherepanov@artifex.com> | 2008-05-06 20:59:54 +0000 |
---|---|---|
committer | Alex Cherepanov <alex.cherepanov@artifex.com> | 2008-05-06 20:59:54 +0000 |
commit | b0e07ef1e8980428b2ab1b7dac0fd660b373e8c1 (patch) | |
tree | 7edfca09e55d8708a508e50c7afd9093ab34ace4 | |
parent | e80cedad2fbabad9d24ac618ef3d712070f851db (diff) |
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. Bug 689812.
DIFFERENCES:
None
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@8707 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r-- | gs/lib/pdf_ops.ps | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/gs/lib/pdf_ops.ps b/gs/lib/pdf_ops.ps index ad910fae9..63fa55c06 100644 --- a/gs/lib/pdf_ops.ps +++ b/gs/lib/pdf_ops.ps @@ -94,25 +94,26 @@ nodict readonly pop if def } bdef -% Restore graphics state, but do not modify path. Paths are not part -% of the PDF graphics state; see 4.4.1 of PDF reference 3rd ed. -/grestore_nopath { - % Collect the upath with an identity CTM - matrix setmatrix .getpath - % Save the CTM, set identity during the uappend, then set the CTM - grestore matrix currentmatrix matrix setmatrix - exch newpath { exec } forall setmatrix -} bdef - /q { gsave //nodict begin } bdef + % Some PDF files have excess Q operators! /Q { currentdict /self .knownget { - exec //nodict eq { end grestore_nopath false } { true } ifelse + exec //nodict eq { + end + % Restore graphics state, but do not modify path. Paths are not part + % of the PDF graphics state; see 4.4.1 of PDF reference 3rd ed. + % Collecting the path with one ctm and re-playing it with another ctm + % transforms the path exactly as PDF needs. + .getpath grestore newpath { exec } forall + //false + } { + //true + } ifelse } { - true % formaterror -- not a gsave dict + //true % formaterror -- not a gsave dict } ifelse { (\n **** File has imbalanced q/Q operators \(too many Q's\) ****\n) pdfformaterror |