+@@ -3824,6 +3833,7 @@
+ out->beginTransparencyGroup(state, bbox, blendingColorSpace,
+ isolated, knockout, softMask);
+ }
++ GfxState*old_state = state;
+
+ // set new base matrix
+ for (i = 0; i < 6; ++i) {
+@@ -3835,6 +3845,9 @@
+ display(str, gFalse);
+
+ if (softMask || transpGroup) {
++ // restore graphics state
++ while(state != old_state)
++ restoreState();
+ out->endTransparencyGroup(state);
+ }
+
+--- TextOutputDev.h.orig 2009-10-07 17:00:29.000000000 -0700
++++ TextOutputDev.h 2009-10-07 17:01:50.000000000 -0700
+@@ -170,6 +170,7 @@
+ friend class TextFlow;
+ friend class TextWordList;
+ friend class TextPage;
++ friend class XMLOutputDev;
+ };
+
+ //------------------------------------------------------------------------
+@@ -578,7 +579,7 @@
+ //----- initialization and control
+
+ // Start a page.
+- virtual void startPage(int pageNum, GfxState *state);
++ virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
+
+ // End a page.
+ virtual void endPage();