There are quite a few options that were removed as part of the
GlobalParams/XpdfParams split; psPaperSize is the one I spotted (patch
attached), but there's also psImageableArea, etc.

It might be better to import the config file parser from xpdf as-is, and
modify it to change Poppler GlobalParams where they exist, rather than
trying to use Poppler's parser?

-- 
Adam Sampson <a...@offog.org>                         <http://offog.org/>
>From 58edfd648e7f189bc5f41c8979985318b3fb2963 Mon Sep 17 00:00:00 2001
From: Adam Sampson <a...@offog.org>
Date: Sun, 4 May 2014 12:46:06 +0100
Subject: [PATCH 2/2] Re-add the psPaperSize config file option.

This was also removed as part of the XpdfParams cleanup, but poppler
doesn't have an equivalent.
---
 xpdf/XPDFParams.cc | 24 ++++++++++++++++++++++++
 xpdf/XPDFParams.h  |  1 +
 2 files changed, 25 insertions(+)

diff --git a/xpdf/XPDFParams.cc b/xpdf/XPDFParams.cc
index 0a0f234..f03c33a 100644
--- a/xpdf/XPDFParams.cc
+++ b/xpdf/XPDFParams.cc
@@ -218,6 +218,28 @@ void XpdfParams::parsePSFile(GooList *tokens, GooString 
*fileName, int line) {
   psFile = ((GooString *)tokens->get(1))->copy();
 }
 
+void XpdfParams::parsePSPaperSize(GooList *tokens, GooString *fileName,
+                                  int line) {
+  GooString *tok;
+
+  if (tokens->getLength() == 2) {
+    tok = (GooString *)tokens->get(1);
+    if (!setPSPaperSize(tok->getCString())) {
+      error(errConfig, -1,
+            "Bad 'psPaperSize' config file command ({0:s}:{1:d})",
+            fileName, line);
+    }
+  } else if (tokens->getLength() == 3) {
+    tok = (GooString *)tokens->get(1);
+    psPaperWidth = atoi(tok->getCString());
+    tok = (GooString *)tokens->get(2);
+    psPaperHeight = atoi(tok->getCString());
+  } else {
+    error(errConfig, -1, "Bad 'psPaperSize' config file command ({0:t}:{1:d})",
+          fileName, line);
+  }
+}
+
 void XpdfParams::parseInitialZoom(GooList *tokens,
                                   GooString *fileName, int line) {
   if (tokens->getLength() != 2) {
@@ -285,6 +307,8 @@ void XpdfParams::parseLine(char *buf, GooString *fileName, 
int line) {
       }
     } else if (!cmd->cmp("psFile")) {
       parsePSFile(tokens, fileName, line);
+    } else if (!cmd->cmp("psPaperSize")) {
+      parsePSPaperSize(tokens, fileName, line);
     } else if (!cmd->cmp("psCrop")) {
       parseYesNo("psCrop", &psCrop, tokens, fileName, line);
     } else if (!cmd->cmp("psDuplex")) {
diff --git a/xpdf/XPDFParams.h b/xpdf/XPDFParams.h
index b3458cb..7160712 100644
--- a/xpdf/XPDFParams.h
+++ b/xpdf/XPDFParams.h
@@ -108,6 +108,7 @@ private:
                   GooList *tokens, GooString *fileName, int line);
   GBool parseYesNo2(char *token, GBool *flag);
   void parsePSFile(GooList *tokens, GooString *fileName, int line);
+  void parsePSPaperSize(GooList *tokens, GooString *fileName, int line);
   void parseInitialZoom(GooList *tokens, GooString *fileName, int line);
   void parseFile(GooString *fileName, FILE *f);
   void parseLine(char *buf, GooString *fileName, int line);
-- 
1.8.5.1

Reply via email to