]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/pdftops.cc
Enanche the find interface to be really able to do multi page find.
[evince.git] / pdf / xpdf / pdftops.cc
index d5d2de85d38fcf50255062eab3e9f2079eb42454..cb230a7fb80d29ff5609ed86c71e5d15e666cefd 100644 (file)
@@ -2,7 +2,7 @@
 //
 // pdftops.cc
 //
-// Copyright 1996-2002 Glyph & Cog, LLC
+// Copyright 1996-2003 Glyph & Cog, LLC
 //
 //========================================================================
 
@@ -25,7 +25,7 @@
 #include "PDFDoc.h"
 #include "PSOutputDev.h"
 #include "Error.h"
-#include "config.h"
+#include "xpdfconfig.h"
 
 static int firstPage = 1;
 static int lastPage = 0;
@@ -47,72 +47,84 @@ static GBool noEmbedCIDTTFonts = gFalse;
 static char paperSize[15] = "";
 static int paperWidth = 0;
 static int paperHeight = 0;
+static GBool noCrop = gFalse;
+static GBool expand = gFalse;
+static GBool noShrink = gFalse;
+static GBool noCenter = gFalse;
 static GBool duplex = gFalse;
-static char ownerPassword[33] = "";
-static char userPassword[33] = "";
+static char ownerPassword[33] = "\001";
+static char userPassword[33] = "\001";
 static GBool quiet = gFalse;
 static char cfgFileName[256] = "";
 static GBool printVersion = gFalse;
 static GBool printHelp = gFalse;
 
 static ArgDesc argDesc[] = {
-  {"-f",      argInt,      &firstPage,      0,
+  {"-f",          argInt,      &firstPage,      0,
    "first page to print"},
-  {"-l",      argInt,      &lastPage,       0,
+  {"-l",          argInt,      &lastPage,       0,
    "last page to print"},
-  {"-level1", argFlag,     &level1,         0,
+  {"-level1",     argFlag,     &level1,         0,
    "generate Level 1 PostScript"},
-  {"-level1sep", argFlag,  &level1Sep,      0,
+  {"-level1sep",  argFlag,     &level1Sep,      0,
    "generate Level 1 separable PostScript"},
-  {"-level2", argFlag,     &level2,         0,
+  {"-level2",     argFlag,     &level2,         0,
    "generate Level 2 PostScript"},
-  {"-level2sep", argFlag,  &level2Sep,      0,
+  {"-level2sep",  argFlag,     &level2Sep,      0,
    "generate Level 2 separable PostScript"},
-  {"-level3", argFlag,     &level3,         0,
+  {"-level3",     argFlag,     &level3,         0,
    "generate Level 3 PostScript"},
-  {"-level3sep", argFlag,  &level3Sep,      0,
+  {"-level3sep",  argFlag,     &level3Sep,      0,
    "generate Level 3 separable PostScript"},
-  {"-eps",    argFlag,     &doEPS,          0,
+  {"-eps",        argFlag,     &doEPS,          0,
    "generate Encapsulated PostScript (EPS)"},
-  {"-form",   argFlag,     &doForm,         0,
+  {"-form",       argFlag,     &doForm,         0,
    "generate a PostScript form"},
 #if OPI_SUPPORT
-  {"-opi",    argFlag,     &doOPI,          0,
+  {"-opi",        argFlag,     &doOPI,          0,
    "generate OPI comments"},
 #endif
-  {"-noembt1", argFlag,     &noEmbedT1Fonts, 0,
+  {"-noembt1",    argFlag,     &noEmbedT1Fonts, 0,
    "don't embed Type 1 fonts"},
-  {"-noembtt", argFlag,    &noEmbedTTFonts, 0,
+  {"-noembtt",    argFlag,     &noEmbedTTFonts, 0,
    "don't embed TrueType fonts"},
-  {"-noembcidps", argFlag, &noEmbedCIDPSFonts, 0,
+  {"-noembcidps", argFlag,     &noEmbedCIDPSFonts, 0,
    "don't embed CID PostScript fonts"},
-  {"-noembcidtt", argFlag, &noEmbedCIDTTFonts, 0,
+  {"-noembcidtt", argFlag, &noEmbedCIDTTFonts,  0,
    "don't embed CID TrueType fonts"},
-  {"-paper",  argString,   paperSize,       sizeof(paperSize),
-   "paper size (letter, legal, A4, A3)"},
-  {"-paperw", argInt,      &paperWidth,     0,
+  {"-paper",      argString,   paperSize,       sizeof(paperSize),
+   "paper size (letter, legal, A4, A3, match)"},
+  {"-paperw",     argInt,      &paperWidth,     0,
    "paper width, in points"},
-  {"-paperh", argInt,      &paperHeight,    0,
+  {"-paperh",     argInt,      &paperHeight,    0,
    "paper height, in points"},
-  {"-duplex", argFlag,     &duplex,         0,
+  {"-nocrop",     argFlag,     &noCrop,         0,
+   "don't crop pages to CropBox"},
+  {"-expand",     argFlag,     &expand,         0,
+   "expand pages smaller than the paper size"},
+  {"-noshrink",   argFlag,     &noShrink,       0,
+   "don't shrink pages larger than the paper size"},
+  {"-nocenter",   argFlag,     &noCenter,       0,
+   "don't center pages smaller than the paper size"},
+  {"-duplex",     argFlag,     &duplex,         0,
    "enable duplex printing"},
-  {"-opw",    argString,   ownerPassword,   sizeof(ownerPassword),
+  {"-opw",        argString,   ownerPassword,   sizeof(ownerPassword),
    "owner password (for encrypted files)"},
-  {"-upw",    argString,   userPassword,    sizeof(userPassword),
+  {"-upw",        argString,   userPassword,    sizeof(userPassword),
    "user password (for encrypted files)"},
-  {"-q",      argFlag,     &quiet,          0,
+  {"-q",          argFlag,     &quiet,          0,
    "don't print any messages or errors"},
   {"-cfg",        argString,      cfgFileName,    sizeof(cfgFileName),
    "configuration file to use in place of .xpdfrc"},
-  {"-v",      argFlag,     &printVersion,   0,
+  {"-v",          argFlag,     &printVersion,   0,
    "print copyright and version info"},
-  {"-h",      argFlag,     &printHelp,      0,
+  {"-h",          argFlag,     &printHelp,      0,
    "print usage information"},
-  {"-help",   argFlag,     &printHelp,      0,
+  {"-help",       argFlag,     &printHelp,      0,
    "print usage information"},
-  {"--help",  argFlag,     &printHelp,      0,
+  {"--help",      argFlag,     &printHelp,      0,
    "print usage information"},
-  {"-?",      argFlag,     &printHelp,      0,
+  {"-?",          argFlag,     &printHelp,      0,
    "print usage information"},
   {NULL}
 };
@@ -181,6 +193,7 @@ int main(int argc, char *argv[]) {
   if (paperSize[0]) {
     if (!globalParams->setPSPaperSize(paperSize)) {
       fprintf(stderr, "Invalid paper size\n");
+      delete fileName;
       goto err0;
     }
   } else {
@@ -191,6 +204,18 @@ int main(int argc, char *argv[]) {
       globalParams->setPSPaperHeight(paperHeight);
     }
   }
+  if (noCrop) {
+    globalParams->setPSCrop(gFalse);
+  }
+  if (expand) {
+    globalParams->setPSExpandSmaller(gTrue);
+  }
+  if (noShrink) {
+    globalParams->setPSShrinkLarger(gFalse);
+  }
+  if (noCenter) {
+    globalParams->setPSCenter(gFalse);
+  }
   if (duplex) {
     globalParams->setPSDuplex(duplex);
   }
@@ -219,12 +244,12 @@ int main(int argc, char *argv[]) {
   }
 
   // open PDF file
-  if (ownerPassword[0]) {
+  if (ownerPassword[0] != '\001') {
     ownerPW = new GString(ownerPassword);
   } else {
     ownerPW = NULL;
   }
-  if (userPassword[0]) {
+  if (userPassword[0] != '\001') {
     userPW = new GString(userPassword);
   } else {
     userPW = NULL;
@@ -280,7 +305,8 @@ int main(int argc, char *argv[]) {
   psOut = new PSOutputDev(psFileName->getCString(), doc->getXRef(),
                          doc->getCatalog(), firstPage, lastPage, mode);
   if (psOut->isOk()) {
-    doc->displayPages(psOut, firstPage, lastPage, 72, 0, gFalse);
+    doc->displayPages(psOut, firstPage, lastPage, 72, 72,
+                     0, globalParams->getPSCrop(), gFalse);
   } else {
     delete psOut;
     exitCode = 2;
@@ -295,8 +321,8 @@ int main(int argc, char *argv[]) {
   delete psFileName;
  err1:
   delete doc;
-  delete globalParams;
  err0:
+  delete globalParams;
 
   // check for memory leaks
   Object::memCheck(stderr);