[poppler] poppler/Gfx.cc poppler/GfxState.h

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Aug 1 06:14:52 PDT 2009


 poppler/Gfx.cc     |   13 +++++++++++++
 poppler/GfxState.h |    1 +
 2 files changed, 14 insertions(+)

New commits:
commit 173451730948c320f16a0f5924a58302603eca0b
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Aug 1 15:13:35 2009 +0200

    Try to workaround some incorrect PDF
    
    Fixes rendering of PDF where forms/patterns have more q than Q. Fixes
    rendering in splash of pdf in bugs #22835, #21899 and #16402

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index eeefcac..ccf818a 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4274,8 +4274,21 @@ void Gfx::doForm1(Object *str, Dict *resDict, double *matrix, double *bbox,
     baseMatrix[i] = state->getCTM()[i];
   }
 
+  GfxState *stateBefore = state;
+
   // draw the form
   display(str, gFalse);
+  
+  if (stateBefore != state) {
+    if (state->isParentState(stateBefore)) {
+      error(-1, "There's a form with more q than Q, trying to fix");
+      while (stateBefore != state) {
+        restoreState();
+      }
+    } else {
+      error(-1, "There's a form with more Q than q");
+    }
+  }
 
   if (softMask || transpGroup) {
     out->endTransparencyGroup(state);
diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index 536c86a..51a317d 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -1269,6 +1269,7 @@ public:
   GfxState *save();
   GfxState *restore();
   GBool hasSaves() { return saved != NULL; }
+  GBool isParentState(GfxState *state) { return saved == state || (saved && saved->isParentState(state)); }
 
   // Misc
   GBool parseBlendMode(Object *obj, GfxBlendMode *mode);


More information about the poppler mailing list