From 83637956c646449b6df04909ab7abe9440ce584c Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 20 Dec 2013 07:19:21 +1030 Subject: [PATCH 4/5] pdftops: Remove origpagesizes mode and make -origpagesizes an alias for -paper match Bug 72312 --- poppler/PSOutputDev.cc | 9 ++------- poppler/PSOutputDev.h | 4 ++-- utils/pdftops.1 | 30 ++++++++++-------------------- utils/pdftops.cc | 23 ++++++++++++++--------- 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index abc2658..f75a397 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -1216,6 +1216,7 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, mode = modeA; paperWidth = paperWidthA; paperHeight = paperHeightA; + noCrop = noCropA; imgLLX = imgLLXA; imgLLY = imgLLYA; imgURX = imgURXA; @@ -1438,7 +1439,6 @@ void PSOutputDev::writeHeader(int firstPage, int lastPage, int i; switch (mode) { - case psModePSOrigPageSizes: case psModePS: writePS("%!PS-Adobe-3.0\n"); break; @@ -1480,10 +1480,6 @@ void PSOutputDev::writeHeader(int firstPage, int lastPage, } switch (mode) { - case psModePSOrigPageSizes: - paperMatch = gTrue; - prevWidth = 0; - prevHeight = 0; case psModePS: for (i = 0; i < paperSizes->getLength(); ++i) { size = (PSOutPaperSize *)paperSizes->get(i); @@ -3552,7 +3548,7 @@ void PSOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { PSOutPaperSize *paperSize; xref = xrefA; - if (mode == psModePS || mode == psModePSOrigPageSizes) { + if (mode == psModePS) { GooString pageLabel; const GBool gotLabel = doc->getCatalog()->indexToLabel(pageNum -1, &pageLabel); if (gotLabel) { @@ -3597,7 +3593,6 @@ void PSOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { xScale = yScale = 1; switch (mode) { - case psModePSOrigPageSizes: case psModePS: // rotate, translate, and scale page imgWidth = imgURX - imgLLX; diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h index f14f03f..c654d2e 100644 --- a/poppler/PSOutputDev.h +++ b/poppler/PSOutputDev.h @@ -68,8 +68,7 @@ class PSOutputDev; enum PSOutMode { psModePS, psModeEPS, - psModeForm, - psModePSOrigPageSizes + psModeForm }; enum PSFileType { @@ -411,6 +410,7 @@ private: imgURX, imgURY; GBool preload; // load all images into memory, and // predefine forms + GBool noCrop; PSOutputFunc outputFunc; void *outputStream; diff --git a/utils/pdftops.1 b/utils/pdftops.1 index dd8c84b..ca26bcc 100644 --- a/utils/pdftops.1 +++ b/utils/pdftops.1 @@ -65,29 +65,18 @@ CID font embedding. Generate Level 3 separable PostScript. The separation handling is the same as for \-level2sep. .TP -.B \-origpagesizes -Generate a PostScript file with variable page sizes and orientations, -taking for each page the size of the original page in the PDF file. -The PostScript file contains "<> setpagedevice" -lines in each page header, so that the paper input tray gets correctly -changed on the printer. This option should be used when pdftops is used -as a print filter. Any specification of the page size via \-paper, -\-paperw, or \-paperh will get overridden as long as each page of the -PDF file has a defined paper size. No more than one of the mode options -(\-origpagesizes, \-eps, \-form) may be given. -.TP .B \-eps Generate an Encapsulated PostScript (EPS) file. An EPS file contains a single image, so if you use this option with a multi-page PDF file, you must use \-f and \-l to specify a single page. No more than one of -the mode options (\-origpagesizes, \-eps, \-form) may be given. +the mode options (\-eps, \-form) may be given. .TP .B \-form Generate a PostScript form which can be imported by software that understands forms. A form contains a single page, so if you use this option with a multi-page PDF file, you must use \-f and \-l to specify a single page. The \-level1 option cannot be used with \-form. No more -than one of the mode options (\-origpagesizes, \-eps, \-form) may be +than one of the mode options (\-eps, \-form) may be given. .TP .B \-opi @@ -144,17 +133,18 @@ preload images and forms .TP .BI \-paper " size" Set the paper size to one of "letter", "legal", "A4", or "A3". This -can also be set to "match", which will set the paper size to match the -size specified in the PDF file. \-origpagesizes overrides this setting -if the PDF file has defined page sizes. +can also be set to "match", which will set the paper size of each page to match the +size specified in the PDF file. If none the \-paper, \-paperw, or \-paperh +options are spoecified the default is to match the paper size. .TP .BI \-paperw " size" -Set the paper width, in points. \-origpagesizes overrides this setting -if the PDF file has defined page sizes. +Set the paper width, in points. .TP .BI \-paperh " size" -Set the paper height, in points. \-origpagesizes overrides this setting -if the PDF file has defined page sizes. +Set the paper height, in points. +.TP +.B \-origpagesizes +This option is the same as "\-paper match". .TP .B \-nocrop By default, output is cropped to the CropBox specified in the PDF diff --git a/utils/pdftops.cc b/utils/pdftops.cc index b54fd42..e003baa 100644 --- a/utils/pdftops.cc +++ b/utils/pdftops.cc @@ -81,7 +81,7 @@ static GBool level2 = gFalse; static GBool level2Sep = gFalse; static GBool level3 = gFalse; static GBool level3Sep = gFalse; -static GBool doOrigPageSizes = gFalse; +static GBool origPageSizes = gFalse; static GBool doEPS = gFalse; static GBool doForm = gFalse; #if OPI_SUPPORT @@ -129,7 +129,7 @@ static const ArgDesc argDesc[] = { "generate Level 3 PostScript"}, {"-level3sep", argFlag, &level3Sep, 0, "generate Level 3 separable PostScript"}, - {"-origpagesizes",argFlag, &doOrigPageSizes,0, + {"-origpagesizes",argFlag, &origPageSizes,0, "conserve original page sizes"}, {"-eps", argFlag, &doEPS, 0, "generate Encapsulated PostScript (EPS)"}, @@ -231,10 +231,9 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Error: use only one of the 'level' options.\n"); exit(1); } - if ((doOrigPageSizes ? 1 : 0) + - (doEPS ? 1 : 0) + + if ((doEPS ? 1 : 0) + (doForm ? 1 : 0) > 1) { - fprintf(stderr, "Error: use only one of -origpagesizes, -eps, and -form\n"); + fprintf(stderr, "Error: use only one of -eps, and -form\n"); exit(1); } if (level1) { @@ -254,15 +253,21 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Error: forms are only available with Level 2 output.\n"); exit(1); } - mode = doOrigPageSizes ? psModePSOrigPageSizes - : doEPS ? psModeEPS - : doForm ? psModeForm - : psModePS; + mode = doEPS ? psModeEPS + : doForm ? psModeForm + : psModePS; fileName = new GooString(argv[1]); // read config file globalParams = new GlobalParams(); + if (origPageSizes) { + paperWidth = paperHeight = -1; + } if (paperSize[0]) { + if (origPageSizes) { + fprintf(stderr, "Error: -origpagesizes and -paper may not be used together.\n"); + exit(1); + } if (!setPSPaperSize(paperSize, paperWidth, paperHeight)) { fprintf(stderr, "Invalid paper size\n"); delete fileName; -- 1.8.3.2