--- poppler-0.11.0.orig/poppler/PSOutputDev.h +++ poppler-0.11.0/poppler/PSOutputDev.h @@ -53,7 +53,8 @@ enum PSOutMode { psModePS, psModeEPS, - psModeForm + psModeForm, + psModePSOrigPageSizes }; enum PSFileType { --- poppler-0.11.0.orig/poppler/PSOutputDev.cc +++ poppler-0.11.0/poppler/PSOutputDev.cc @@ -1269,6 +1269,7 @@ Object info, obj1; switch (mode) { + case psModePSOrigPageSizes: case psModePS: writePS("%!PS-Adobe-3.0\n"); break; @@ -1299,6 +1300,7 @@ writePS("%%DocumentSuppliedResources: (atend)\n"); switch (mode) { + case psModePSOrigPageSizes: case psModePS: writePSFmt("%%DocumentMedia: plain {0:d} {1:d} 0 () ()\n", paperWidth, paperHeight); @@ -3122,7 +3124,7 @@ GBool landscape; - if (mode == psModePS) { + if (mode == psModePS || mode == psModePSOrigPageSizes) { GooString pageLabel; const GBool gotLabel = m_catalog->indexToLabel(pageNum -1, &pageLabel); if (gotLabel) { @@ -3150,6 +3152,27 @@ switch (mode) { + case psModePSOrigPageSizes: + x1 = (int)floor(state->getX1()); + y1 = (int)floor(state->getY1()); + x2 = (int)ceil(state->getX2()); + y2 = (int)ceil(state->getY2()); + width = x2 - x1; + height = y2 - y1; + if (width > height) { + landscape = gTrue; + } else { + landscape = gFalse; + } + writePSFmt("%%PageOrientation: {0:s}\n", + landscape ? "Landscape" : "Portrait"); + writePSFmt("<> setpagedevice\n", width, height); + writePS("pdfStartPage\n"); + writePSFmt("{0:d} {1:d} {2:d} {3:d} re W\n", x1, y1, x2 - x1, y2 - y1); + writePS("%%EndPageSetup\n"); + ++seqPage; + break; + case psModePS: // rotate, translate, and scale page imgWidth = imgURX - imgLLX; --- poppler-0.11.0.orig/utils/pdftops.cc +++ poppler-0.11.0/utils/pdftops.cc @@ -74,6 +74,7 @@ static GBool level2Sep = gFalse; static GBool level3 = gFalse; static GBool level3Sep = gFalse; +static GBool doOrigPageSizes = gFalse; static GBool doEPS = gFalse; static GBool doForm = gFalse; #if OPI_SUPPORT @@ -115,6 +116,8 @@ "generate Level 3 PostScript"}, {"-level3sep", argFlag, &level3Sep, 0, "generate Level 3 separable PostScript"}, + {"-origpagesizes",argFlag, &doOrigPageSizes,0, + "conserve original page sizes"}, {"-eps", argFlag, &doEPS, 0, "generate Encapsulated PostScript (EPS)"}, {"-form", argFlag, &doForm, 0, @@ -202,8 +205,10 @@ fprintf(stderr, "Error: use only one of the 'level' options.\n"); exit(1); } - if (doEPS && doForm) { - fprintf(stderr, "Error: use only one of -eps and -form\n"); + if ((doOrigPageSizes ? 1 : 0) + + (doEPS ? 1 : 0) + + (doForm ? 1 : 0) > 1) { + fprintf(stderr, "Error: use only one of -origpagesizes, -eps, and -form\n"); exit(1); } if (level1) { @@ -223,9 +228,10 @@ fprintf(stderr, "Error: forms are only available with Level 2 output.\n"); exit(1); } - mode = doEPS ? psModeEPS - : doForm ? psModeForm - : psModePS; + mode = doOrigPageSizes ? psModePSOrigPageSizes + : doEPS ? psModeEPS + : doForm ? psModeForm + : psModePS; fileName = new GooString(argv[1]); // read config file