I was about to file a bug for this myself...

The problem is that the GlobalParams/XpdfParams splitting patch applied
in xpdf 3.03-12 accidentally removed the code that set parameters from
command-line options and resources. Here's a patch to fix it, which
should make -z, -cont, -paper, -paperw and -paperh (and the equivalent
resources) work again. It also fixes -ps, which was being set in
GlobalParams but read from XpdfParams.

Note that the splitting patch also removed a bunch of config file
options (see #739271 for an example of this).

-- 
Adam Sampson <a...@offog.org>                         <http://offog.org/>
>From cb0312298fe6059ac97da382e3b923b991983d02 Mon Sep 17 00:00:00 2001
From: Adam Sampson <a...@offog.org>
Date: Sun, 4 May 2014 12:43:56 +0100
Subject: [PATCH 1/2] Fix command-line parameters -z, -cont etc.

The Debian patch that moved initialZoom and other xpdf-specific
parameters from GlobalParams into XPDFParams accidentally removed the
code that set them in response to command-line options and resources, so
"-z page" or the equivalent resource didn't work.

psFile exists in both GlobalParams and XPDFParams; be consistent about
using the latter for xpdf's purposes.
---
 xpdf/XPDFParams.cc | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 xpdf/XPDFParams.h  | 12 +++++++++++
 xpdf/xpdf.cc       | 23 +++++++++++++++++++++-
 3 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/xpdf/XPDFParams.cc b/xpdf/XPDFParams.cc
index 18bbf24..0a0f234 100644
--- a/xpdf/XPDFParams.cc
+++ b/xpdf/XPDFParams.cc
@@ -490,3 +490,61 @@ int XpdfParams::getPSPaperHeight() {
   unlockXpdfParams;
   return h;
 }
+
+void XpdfParams::setPSFile(char *file) {
+  lockXpdfParams;
+  if (psFile) {
+    delete psFile;
+  }
+  psFile = new GooString(file);
+  unlockXpdfParams;
+}
+
+GBool XpdfParams::setPSPaperSize(char *size) {
+  lockXpdfParams;
+  if (!strcmp(size, "match")) {
+    psPaperWidth = psPaperHeight = -1;
+  } else if (!strcmp(size, "letter")) {
+    psPaperWidth = 612;
+    psPaperHeight = 792;
+  } else if (!strcmp(size, "legal")) {
+    psPaperWidth = 612;
+    psPaperHeight = 1008;
+  } else if (!strcmp(size, "A4")) {
+    psPaperWidth = 595;
+    psPaperHeight = 842;
+  } else if (!strcmp(size, "A3")) {
+    psPaperWidth = 842;
+    psPaperHeight = 1190;
+  } else {
+    unlockXpdfParams;
+    return gFalse;
+  }
+  unlockXpdfParams;
+  return gTrue;
+}
+
+void XpdfParams::setPSPaperWidth(int width) {
+  lockXpdfParams;
+  psPaperWidth = width;
+  unlockXpdfParams;
+}
+
+void XpdfParams::setPSPaperHeight(int height) {
+  lockXpdfParams;
+  psPaperHeight = height;
+  unlockXpdfParams;
+}
+
+void XpdfParams::setInitialZoom(char *s) {
+  lockXpdfParams;
+  delete initialZoom;
+  initialZoom = new GooString(s);
+  unlockXpdfParams;
+}
+
+void XpdfParams::setContinuousView(GBool cont) {
+  lockXpdfParams;
+  continuousView = cont;
+  unlockXpdfParams;
+}
diff --git a/xpdf/XPDFParams.h b/xpdf/XPDFParams.h
index dc5e85d..b3458cb 100644
--- a/xpdf/XPDFParams.h
+++ b/xpdf/XPDFParams.h
@@ -77,6 +77,9 @@ public:
   XpdfParams(char *cfgFileName);
   ~XpdfParams();
   void createDefaultKeyBindings();
+
+  //----- accessors
+
   GooList *getKeyBinding(int code, int mods, int context);
   GooString *getLaunchCommand() { return launchCommand; }
   GooString *getURLCommand() { return urlCommand; }
@@ -89,6 +92,15 @@ public:
   int getPSPaperWidth();
   int getPSPaperHeight();
 
+  //----- functions to set parameters
+
+  void setPSFile(char *file);
+  GBool setPSPaperSize(char *size);
+  void setPSPaperWidth(int width);
+  void setPSPaperHeight(int height);
+  void setInitialZoom(char *s);
+  void setContinuousView(GBool cont);
+
 private:
   void parseCommand(const char *cmdName, GooString **val,
                     GooList *tokens, GooString *fileName, int line);
diff --git a/xpdf/xpdf.cc b/xpdf/xpdf.cc
index 5ce77fd..56910f1 100644
--- a/xpdf/xpdf.cc
+++ b/xpdf/xpdf.cc
@@ -160,8 +160,23 @@ int main(int argc, char *argv[]) {
   globalParams = new GlobalParams(cfgFileName);
   xpdfParams = new XpdfParams(cfgFileName);
   globalParams->setupBaseFonts(NULL);
+  if (contView) {
+    xpdfParams->setContinuousView(contView);
+  }
   if (psFileArg[0]) {
-    globalParams->setPSFile(psFileArg);
+    xpdfParams->setPSFile(psFileArg);
+  }
+  if (paperSize[0]) {
+    if (!xpdfParams->setPSPaperSize(paperSize)) {
+      fprintf(stderr, "Invalid paper size\n");
+    }
+  } else {
+    if (paperWidth) {
+      xpdfParams->setPSPaperWidth(paperWidth);
+    }
+    if (paperHeight) {
+      xpdfParams->setPSPaperHeight(paperHeight);
+    }
   }
   if (level1) {
     globalParams->setPSLevel(psLevel1);
@@ -199,6 +214,12 @@ int main(int argc, char *argv[]) {
   // create the XPDFApp object
   app = new XPDFApp(&argc, argv);
 
+  // the initialZoom parameter can be set in either the config file or
+  // as an X resource (or command line arg)
+  if (app->getInitialZoom()) {
+    xpdfParams->setInitialZoom(app->getInitialZoom()->getCString());
+  }
+
   // check command line
   ok = ok && argc >= 1 && argc <= 3;
   if (remoteCmd[0]) {
-- 
1.8.5.1

Reply via email to