Hi List,
Here's a patch to allow optionally using the cropbox rather than
mediabox in pdftoppm.
cheers,
Richard
--- utils/pdftoppm.cc.old 2008-11-28 12:03:22.000000000 +0000
+++ utils/pdftoppm.cc 2008-11-28 12:03:34.000000000 +0000
@@ -45,6 +45,7 @@
static int w = 0;
static int h = 0;
static int sz = 0;
+static GBool useCropBox = gFalse;
static GBool mono = gFalse;
static GBool gray = gFalse;
static char enableFreeTypeStr[16] = "";
@@ -77,6 +78,8 @@
"height of crop area in pixels (default is 0)"},
{"-sz", argInt, &sz, 0,
"size of crop square in pixels (sets W and H)"},
+ {"-cropbox",argFlag, &useCropBox, 0,
+ "use the crop box rather than media box"},
{"-mono", argFlag, &mono, 0,
"generate a monochrome PBM file"},
@@ -125,7 +128,7 @@
doc->displayPageSlice(splashOut,
pg, resolution, resolution,
0,
- gTrue, gFalse, gFalse,
+ !useCropBox, gFalse, gFalse,
x, y, w, h
);
if (ppmFile != NULL) {
@@ -236,8 +239,14 @@
if (sz != 0) w = h = sz;
pg_num_len = (int)ceil(log((double)doc->getNumPages()) / log((double)10));
for (pg = firstPage; pg <= lastPage; ++pg) {
- pg_w = doc->getPageMediaWidth(pg);
- pg_h = doc->getPageMediaHeight(pg);
+ if (useCropBox) {
+ pg_w = doc->getPageCropWidth(pg);
+ pg_h = doc->getPageCropHeight(pg);
+ } else {
+ pg_w = doc->getPageMediaWidth(pg);
+ pg_h = doc->getPageMediaHeight(pg);
+ }
+
if (scaleTo != 0) {
resolution = (72.0 * scaleTo) / (pg_w > pg_h ? pg_w : pg_h);
}
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler