[poppler] poppler and TeX Live -- request for a few modifications

Peter Breitenlohner peb at mppmu.mpg.de
Fri Oct 14 05:11:11 PDT 2011


Hallo,

0. This is a request for a few modifications in the poppler sources in order
to simplify the use of libpoppler for pdfTeX, luaTeX, and XeTeX in TeX Live.

Please answer directly because I am not subscribed to the this list.

Before going into any details, let me recapitulate a bit of history.

Before 2009 pdfTeX was built with a modified version of the xpdf sources in
the TeX Live (TL) source tree.  Some, but not all, of these modifications
were also applied to the xpdf distribution.  As far as I know the
preprocessor macro PDF_PARSER_ONLY was introduces for the benefit of pdfTeX.
When XeTeX and luaTeX were added to TL, they used the same modified xpdf
sources.

In 2009 this was rewritten in terms of patches applied to the xpdf
distribution and some of these patches were later included into the
distribution.

Later in 2009 all three programs were modified such, that they could use
and installed (system) poppler library instead of xpdf from the TL tree.

In 2011, new functionality in luaTeX required to always use poppler, and
thus a subset of the poppler sources had to be added to the TL tree.  The
present status is, that luaTeX and XeTeX always use libpoppler, either from
the TL tree or a system version, whereas pdfTeX still uses xpdf from the TL
tree or a system libpoppler.

At the moment we have to apply a few patches to poppler-0.18.0 as used in
the TL tree.  These patches have to be adapted when upgrading to a newer
poppler version -- an unecessary complication.  Therefore, we request that
these patches discussed below be integrated into the poppler distribution.

1. Although PDF_PARSER_ONLY was introduced for pdfTeX, defining this leads
to compilation errors because this prevents the inclusion of a few headers
while the code that requires these headers is not excluded.

At present we use the attached patch-01-PDF_PARSER_ONLY for poppler,
alternatively something like patch-10-exclude-body-of-Page_getDefaultCTM as
suggested by Derek B. Noonburg for xpdf could be used.

2. There are some problems compiling class WinFontList for mingw.  However,
WinFontList is certainly not required when parsing pdf documents, and thus
we use the attached patch-04-mingw.

3. pdfTeX, luaTeX, and XeTeX want to know the poppler version string to be
displayed when they are invoked with '--version'.  Moreover they use the
plain libpoppler library and not any of the cpp-, glib-, or whatever wrapper
libraries.  Thus we apply the attached patch-03-POPPLER_VERSION and add
   AC_DEFINE_UNQUOTED([POPPLER_VERSION], ["$PACKAGE_VERSION"],
                      [Define to the poppler version.])
to our proxy configure.ac in order to make POPPLER_VERSION available in
poppler-config.h.

4. Finally, although not really necessary, it would be good if you could
apply patch-02-warnings to avoid completely superfluous compiler warnings
(at least from the part of the poppler source tree used for TL).

========================================

We would very much appreciate if the patches discussed above could be
integrated into the poppler distribution.

Regards
Peter Breitenlohner <peb at mppmu.mpg.de>
-------------- next part --------------
diff -ur poppler-0.18.0.orig/poppler/Page.cc poppler-0.18.0/poppler/Page.cc
--- poppler-0.18.0.orig/poppler/Page.cc	2011-03-12 11:49:45.000000000 +0100
+++ poppler-0.18.0/poppler/Page.cc	2011-10-07 20:07:46.000000000 +0200
@@ -45,13 +45,11 @@
 #include "XRef.h"
 #include "Link.h"
 #include "OutputDev.h"
-#ifndef PDF_PARSER_ONLY
 #include "Gfx.h"
 #include "GfxState.h"
 #include "Annot.h"
 #include "TextOutputDev.h"
 #include "Form.h"
-#endif
 #include "Error.h"
 #include "Page.h"
 #include "Catalog.h"
-------------- next part --------------
	Enable compilation with -DPDF_PARSER_ONLY

	from:
		Derek B. Noonburg <derek at foolabs.com>

diff -ur -N xpdf-3.03.orig/xpdf/Page.cc xpdf-3.03/xpdf/Page.cc
--- xpdf-3.03.orig/xpdf/Page.cc	2011-08-15 23:08:53.000000000 +0200
+++ xpdf-3.03/xpdf/Page.cc	2011-08-22 13:52:37.000000000 +0200
@@ -461,6 +461,7 @@
 
 void Page::getDefaultCTM(double *ctm, double hDPI, double vDPI,
 			 int rotate, GBool useMediaBox, GBool upsideDown) {
+#ifndef PDF_PARSER_ONLY
   GfxState *state;
   int i;
 
@@ -477,4 +478,5 @@
     ctm[i] = state->getCTM()[i];
   }
   delete state;
+#endif
 }
-------------- next part --------------
diff -ur poppler-0.18.0.orig/poppler/GlobalParams.cc poppler-0.18.0/poppler/GlobalParams.cc
--- poppler-0.18.0.orig/poppler/GlobalParams.cc	2011-07-28 12:43:53.000000000 +0200
+++ poppler-0.18.0/poppler/GlobalParams.cc	2011-10-07 20:23:51.000000000 +0200
@@ -211,6 +211,7 @@
 
 #endif
 
+#ifndef PDF_PARSER_ONLY
 #ifdef _WIN32
 
 //------------------------------------------------------------------------
@@ -455,6 +456,7 @@
 }
 
 #endif // _WIN32
+#endif // PDF_PARSER_ONLY
 
 //------------------------------------------------------------------------
 // PSFontParam
@@ -709,10 +711,12 @@
   unicodeMapCache = new UnicodeMapCache();
   cMapCache = new CMapCache();
 
+#ifndef PDF_PARSER_ONLY
 #ifdef _WIN32
   baseFontsInitialized = gFalse;
   winFontList = NULL;
 #endif
+#endif
 
 #ifdef ENABLE_PLUGINS
   plugins = new GooList();
@@ -875,9 +879,11 @@
   deleteGooHash(unicodeMaps, GooString);
   deleteGooList(toUnicodeDirs, GooString);
   deleteGooHash(displayFonts, DisplayFontParam);
+#ifndef PDF_PARSER_ONLY
 #ifdef _WIN32
   delete winFontList;
 #endif
+#endif
   deleteGooHash(psFonts, PSFontParam);
   deleteGooList(psNamedFonts16, PSFontParam);
   deleteGooList(psFonts16, PSFontParam);
diff -ur poppler-0.18.0.orig/poppler/GlobalParams.h poppler-0.18.0/poppler/GlobalParams.h
--- poppler-0.18.0.orig/poppler/GlobalParams.h	2011-08-18 17:37:37.000000000 +0200
+++ poppler-0.18.0/poppler/GlobalParams.h	2011-10-07 20:20:43.000000000 +0200
@@ -60,9 +60,11 @@
 class GlobalParams;
 class GfxFont;
 class Stream;
+#ifndef PDF_PARSER_ONLY
 #ifdef _WIN32
 class WinFontList;
 #endif
+#endif
 
 //------------------------------------------------------------------------
 
@@ -306,10 +308,12 @@
   GooList *toUnicodeDirs;		// list of ToUnicode CMap dirs [GooString]
   GooHash *displayFonts;		// display font info, indexed by font name
 				//   [DisplayFontParam]
+#ifndef PDF_PARSER_ONLY
 #ifdef _WIN32
   GBool baseFontsInitialized;
   WinFontList *winFontList;	// system TrueType fonts
 #endif
+#endif
   GBool psExpandSmaller;	// expand smaller pages to fill paper
   GBool psShrinkLarger;		// shrink larger pages to fit paper
   GBool psCenter;		// center pages on the paper
-------------- next part --------------
diff -ur poppler-0.18.0.orig/poppler/poppler-config.h.in poppler-0.18.0/poppler/poppler-config.h.in
--- poppler-0.18.0.orig/poppler/poppler-config.h.in	2011-09-27 00:24:08.000000000 +0200
+++ poppler-0.18.0/poppler/poppler-config.h.in	2011-10-10 19:08:51.000000000 +0200
@@ -14,6 +14,11 @@
 // around #undef look odd, but it's to silence warnings about
 // redefining those symbols.
 
+/* Define to the poppler version. */
+#ifndef POPPLER_VERSION
+#undef POPPLER_VERSION
+#endif
+
 /* Enable multithreading support. */
 #ifndef MULTITHREADED
 #undef MULTITHREADED
-------------- next part --------------
diff -ur poppler-0.18.0.orig/poppler/Annot.cc poppler-0.18.0/poppler/Annot.cc
--- poppler-0.18.0.orig/poppler/Annot.cc	2011-08-25 23:25:21.000000000 +0200
+++ poppler-0.18.0/poppler/Annot.cc	2011-10-07 20:45:57.000000000 +0200
@@ -2643,7 +2643,7 @@
 	y3 = quadrilaterals->getY3(i);
 	x4 = quadrilaterals->getX4(i);
 	y4 = quadrilaterals->getY4(i);
-	h4 = abs(y1 - y3) / 4.0;
+	h4 = fabs(y1 - y3) / 4.0;
 
 	appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x3, y3);
 	appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n",
diff -ur poppler-0.18.0.orig/poppler/GfxState.cc poppler-0.18.0/poppler/GfxState.cc
--- poppler-0.18.0.orig/poppler/GfxState.cc	2011-07-28 12:58:37.000000000 +0200
+++ poppler-0.18.0/poppler/GfxState.cc	2011-10-07 20:52:53.000000000 +0200
@@ -2997,7 +2997,7 @@
 
   getParameterRange(&sMin, &sMax, xMin, yMin, xMax, yMax);
   upperBound = ctm->norm() * getDistance(sMin, sMax);
-  maxSize = ceil(upperBound);
+  maxSize = (int)ceil(upperBound);
   maxSize = std::max<int>(maxSize, 2);
 
   {
diff -ur poppler-0.18.0.orig/poppler/GfxState.h poppler-0.18.0/poppler/GfxState.h
--- poppler-0.18.0.orig/poppler/GfxState.h	2011-07-29 00:25:02.000000000 +0200
+++ poppler-0.18.0/poppler/GfxState.h	2011-10-07 20:43:42.000000000 +0200
@@ -100,7 +100,7 @@
 }
 
 static inline Guchar dblToByte(double x) {
-  return (x * 255.0);
+  return (Guchar)(x * 255.0);
 }
 
 static inline double byteToDbl(Guchar x) {
diff -ur poppler-0.18.0.orig/poppler/Hints.cc poppler-0.18.0/poppler/Hints.cc
--- poppler-0.18.0.orig/poppler/Hints.cc	2011-06-30 23:41:10.000000000 +0200
+++ poppler-0.18.0/poppler/Hints.cc	2011-10-07 21:51:39.000000000 +0200
@@ -413,7 +413,7 @@
 {
   Guint bit, bits;
 
-  if (n < 0) return -1;
+  if (n < 0) return (Guint)-1;
   if (n == 0) return 0;
 
   if (n == 1)
@@ -421,11 +421,11 @@
 
   bit = (readBit(str) << (n-1));
   if (bit == (Guint) -1)
-    return -1;
+    return (Guint)-1;
 
   bits = readBits(n-1, str);
   if (bits == (Guint) -1)
-    return -1;
+    return (Guint)-1;
 
   return bit | bits;
 }
diff -ur poppler-0.18.0.orig/poppler/Lexer.cc poppler-0.18.0/poppler/Lexer.cc
--- poppler-0.18.0.orig/poppler/Lexer.cc	2010-07-16 00:43:51.000000000 +0200
+++ poppler-0.18.0/poppler/Lexer.cc	2011-10-07 20:52:58.000000000 +0200
@@ -215,7 +215,7 @@
 	      overflownUnsignedInteger = gTrue;
 	      xf = xi * 10.0 + (c - '0');
 	    } else {
-	      xui = xi * 10.0 + (c - '0');
+	      xui = (unsigned int)(xi * 10.0 + (c - '0'));
 	    }
 	  } else {
 	    xi = xi * 10 + (c - '0');
diff -ur poppler-0.18.0.orig/poppler/Stream.cc poppler-0.18.0/poppler/Stream.cc
--- poppler-0.18.0.orig/poppler/Stream.cc	2011-07-19 00:17:56.000000000 +0200
+++ poppler-0.18.0/poppler/Stream.cc	2011-10-07 20:52:50.000000000 +0200
@@ -474,7 +474,7 @@
   } else if (nBits == 8) {
     Guchar *line = imgLine;
     int readChars = str->doGetChars(nVals, line);
-    for ( ; readChars < nVals; readChars++) line[readChars] = EOF;
+    for ( ; readChars < nVals; readChars++) line[readChars] = (Guchar)EOF;
   } else if (nBits == 16) {
     // this is a hack to support 16 bits images, everywhere
     // we assume a component fits in 8 bits, with this hack


More information about the poppler mailing list