diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h index 15af90a..baf3b7c 100644 --- a/poppler/OutputDev.h +++ b/poppler/OutputDev.h @@ -111,6 +111,10 @@ public: // Does this device require incCharCount to be called for text on // non-shown layers? virtual GBool needCharCount() { return gFalse; } + + // Does this device need to clip pages to the crop box even when the + // box is the crop box? + virtual GBool needClipToCropBox() { return gFalse; } //----- initialization and control diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h index 809f058..22189f2 100644 --- a/poppler/PSOutputDev.h +++ b/poppler/PSOutputDev.h @@ -151,6 +151,8 @@ public: // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. virtual GBool interpretType3Chars() { return gFalse; } + + virtual GBool needClipToCropBox() { return mode == psModeEPS; } //----- header/trailer (used only if manualCtrl is true) diff --git a/poppler/Page.cc b/poppler/Page.cc index 87bc3a4..8c2065b 100644 --- a/poppler/Page.cc +++ b/poppler/Page.cc @@ -481,6 +481,9 @@ Gfx *Page::createGfx(OutputDev *out, double hDPI, double vDPI, printf("***** Rotate = %d\n", attrs->getRotate()); } + if (!crop) { + crop = (box == *cropBox) && out->needClipToCropBox(); + } gfx = new Gfx(doc, out, num, attrs->getResourceDict(), hDPI, vDPI, &box, crop ? cropBox : (PDFRectangle *)NULL, rotate, abortCheckCbk, abortCheckCbkData); diff --git a/poppler/Page.h b/poppler/Page.h index 78cedc4..a6098ed 100644 --- a/poppler/Page.h +++ b/poppler/Page.h @@ -59,6 +59,8 @@ public: GBool isValid() { return x1 != 0 || y1 != 0 || x2 != 0 || y2 != 0; } GBool contains(double x, double y) { return x1 <= x && x <= x2 && y1 <= y && y <= y2; } void clipTo(PDFRectangle *rect); + + bool operator==(const PDFRectangle &rect) const { return x1 == rect.x1 && y1 == rect.y1 && x2 == rect.x2 && y2 == rect.y2; } }; //------------------------------------------------------------------------