diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc index d054697..97ffaa7 100644 --- a/poppler/TextOutputDev.cc +++ b/poppler/TextOutputDev.cc @@ -4282,10 +4282,13 @@ TextSelectionPainter::TextSelectionPainter(TextPage *page, out->setDefaultCTM (state->getCTM()); state->setFillColorSpace(new GfxDeviceRGBColorSpace()); + + out->saveState(state); } TextSelectionPainter::~TextSelectionPainter() { + out->restoreState(state); out->endPage (); delete state; @@ -4301,6 +4304,8 @@ void TextSelectionPainter::visitLine (TextLine *line, double x1, y1, x2, y2, margin; Matrix ctm, ictm; + out->restoreState(state); + state->setFillColor(box_color); out->updateFillColor(state); @@ -4330,6 +4335,11 @@ void TextSelectionPainter::visitLine (TextLine *line, state->closePath(); out->fill(state); + + // clip any successive visitWord paints until the next visitLine + out->saveState(state); + out->clip(state); + state->clearPath(); }