diff --git a/utils/pdftops.cc b/utils/pdftops.cc index 69d5c32..23f7f09 100644 --- a/utils/pdftops.cc +++ b/utils/pdftops.cc @@ -89,6 +89,7 @@ static GBool noEmbedCIDPSFonts = gFalse; static GBool noEmbedCIDTTFonts = gFalse; static GBool noSubstFonts = gFalse; static GBool preload = gFalse; +static GBool doAutoRotate = gFalse; /* auto rotate landscape pages - added by Ryszard Trojnacki */ static char paperSize[15] = ""; static int paperWidth = -1; static int paperHeight = -1; @@ -122,6 +123,8 @@ static const ArgDesc argDesc[] = { "generate Level 3 separable PostScript"}, {"-origpagesizes",argFlag, &doOrigPageSizes,0, "conserve original page sizes"}, + {"-autorotate",argFlag, &doAutoRotate,0, /* Added by Ryszard Trojnacki */ + "rotate landscape pages to portrait"}, {"-eps", argFlag, &doEPS, 0, "generate Encapsulated PostScript (EPS)"}, {"-form", argFlag, &doForm, 0, @@ -355,8 +358,26 @@ int main(int argc, char *argv[]) { paperHeight, duplex); if (psOut->isOk()) { - doc->displayPages(psOut, firstPage, lastPage, 72, 72, + if(doAutoRotate) { /* Added by Ryszard Trojnacki */ + int page; + + for (page = firstPage; page <= lastPage; ++page) { + Page* pdfpage=doc->getCatalog()->getPage(page); + int rotate=0; + if(pdfpage->getMediaWidth()>pdfpage->getMediaHeight()) { + if (globalParams->getPrintCommands()) { + printf("***** autorotating page %d *****\n",page); + } + rotate=90; + } + + doc->displayPage(psOut, page, 72, 72, rotate, noCrop, !noCrop, gTrue, + NULL, NULL, NULL, NULL); + } + } else { + doc->displayPages(psOut, firstPage, lastPage, 72, 72, 0, noCrop, !noCrop, gTrue); + } } else { delete psOut; exitCode = 2;