diff -rubB org/configure.in new/configure.in --- org/configure.in 2013-02-11 15:50:51.000000000 -0500 +++ new/configure.in 2013-02-11 16:18:59.000000000 -0500 @@ -2499,6 +2499,7 @@ HAVE_POPPLER=no POPPLER_HAS_OPTCONTENT=no POPPLER_BASE_STREAM_HAS_TWO_ARGS=no +POPPLER_0_20_OR_LATER=no AC_MSG_CHECKING([for poppler]) @@ -2558,6 +2559,19 @@ if test -z "`${CXX} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes AC_MSG_RESULT([yes]) + + # And now we check if we have Poppler >= 0.20.0 + AC_MSG_CHECKING([if we have Poppler >= 0.20.0]) + rm -f testpoppler.* + echo '#include ' > testpoppler.cpp + echo 'int main(int argc, char** argv) { setErrorCallback(0,0); return 0; }' >> testpoppler.cpp + if test -z "`${CXX} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then + POPPLER_0_20_OR_LATER=yes + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + else AC_MSG_RESULT([no]) fi @@ -2573,6 +2587,7 @@ AC_SUBST(HAVE_POPPLER, $HAVE_POPPLER) AC_SUBST(POPPLER_HAS_OPTCONTENT, $POPPLER_HAS_OPTCONTENT) AC_SUBST(POPPLER_BASE_STREAM_HAS_TWO_ARGS, $POPPLER_BASE_STREAM_HAS_TWO_ARGS) +AC_SUBST(POPPLER_0_20_OR_LATER, $POPPLER_0_20_OR_LATER) AC_SUBST(POPPLER_INC, $POPPLER_INC) dnl --------------------------------------------------------------------------- diff -rubB org/frmts/pdf/GNUmakefile new/frmts/pdf/GNUmakefile --- org/frmts/pdf/GNUmakefile 2013-02-11 15:50:51.000000000 -0500 +++ new/frmts/pdf/GNUmakefile 2013-02-11 16:18:59.000000000 -0500 @@ -15,6 +15,11 @@ default: $(OBJ:.o=.$(OBJ_EXT)) +ifeq ($(POPPLER_0_20_OR_LATER),yes) +CPPFLAGS += -DPOPPLER_0_20_OR_LATER +endif + + clean: rm -f *.o $(O_OBJ) diff -rubB org/frmts/pdf/makefile.vc new/frmts/pdf/makefile.vc --- org/frmts/pdf/makefile.vc 2013-02-11 15:50:51.000000000 -0500 +++ new/frmts/pdf/makefile.vc 2013-02-11 16:18:59.000000000 -0500 @@ -5,7 +5,7 @@ !INCLUDE $(GDAL_ROOT)\nmake.opt -EXTRAFLAGS = $(POPPLER_CFLAGS) $(POPPLER_HAS_OPTCONTENT_FLAGS) $(POPPLER_BASE_STREAM_HAS_TWO_ARGS_FLAGS) +EXTRAFLAGS = $(POPPLER_CFLAGS) $(POPPLER_HAS_OPTCONTENT_FLAGS) $(POPPLER_BASE_STREAM_HAS_TWO_ARGS_FLAGS) $(POPPLER_0_20_OR_LATER_FLAGS) !IFDEF POPPLER_HAS_OPTCONTENT POPPLER_HAS_OPTCONTENT_FLAGS = -DPOPPLER_HAS_OPTCONTENT @@ -15,6 +15,10 @@ POPPLER_BASE_STREAM_HAS_TWO_ARGS_FLAGS = -DPOPPLER_BASE_STREAM_HAS_TWO_ARGS !ENDIF +!IFDEF POPPLER_0_20_OR_LATER +POPPLER_0_20_OR_LATER_FLAGS = -DPOPPLER_0_20_OR_LATER +!ENDIF + default: $(OBJ) xcopy /D /Y *.obj ..\o diff -rubB org/frmts/pdf/pdfdataset.cpp new/frmts/pdf/pdfdataset.cpp --- org/frmts/pdf/pdfdataset.cpp 2013-02-11 15:50:51.000000000 -0500 +++ new/frmts/pdf/pdfdataset.cpp 2013-02-11 16:19:11.000000000 -0500 @@ -348,7 +348,11 @@ SplashOutputDev *poSplashOut; poSplashOut = new SplashOutputDev(splashModeRGB8, 4, gFalse, sColor); PDFDoc* poDoc = poGDS->poDoc; +#ifdef POPPLER_0_20_OR_LATER + poSplashOut->startDoc(poDoc); +#else poSplashOut->startDoc(poDoc->getXRef()); +#endif double dfDPI = poGDS->dfDPI; /* EVIL: we modify a private member... */ @@ -489,6 +493,21 @@ /* PDFDatasetErrorFunction() */ /************************************************************************/ +#ifdef POPPLER_0_20_OR_LATER +static void PDFDatasetErrorFunction(void* userData, ErrorCategory eErrCatagory, int nPos, char *pszMsg) +{ + CPLString osError; + + if (nPos >= 0) + osError.Printf("Pos = %d, ", nPos); + osError += pszMsg; + + if (strcmp(osError.c_str(), "Incorrect password") == 0) + return; + + CPLError(CE_Failure, CPLE_AppDefined, "%s", osError.c_str()); +} +#else static void PDFDatasetErrorFunction(int nPos, char *pszMsg, va_list args) { CPLString osError; @@ -502,6 +521,7 @@ CPLError(CE_Failure, CPLE_AppDefined, "%s", osError.c_str()); } +#endif /************************************************************************/ /* Open() */ @@ -536,7 +556,11 @@ GooString* poUserPwd = NULL; /* Set custom error handler for poppler errors */ +#ifdef POPPLER_0_20_OR_LATER + setErrorCallback(PDFDatasetErrorFunction, NULL); +#else setErrorFunction(PDFDatasetErrorFunction); +#endif PDFDoc* poDoc = NULL; ObjectAutoFree oObj; diff -rubB org/GDALmake.opt.in new/GDALmake.opt.in --- org/GDALmake.opt.in 2013-02-11 15:50:51.000000000 -0500 +++ new/GDALmake.opt.in 2013-02-11 16:18:59.000000000 -0500 @@ -364,6 +364,7 @@ HAVE_POPPLER = @HAVE_POPPLER@ POPPLER_HAS_OPTCONTENT = @POPPLER_HAS_OPTCONTENT@ POPPLER_BASE_STREAM_HAS_TWO_ARGS = @POPPLER_BASE_STREAM_HAS_TWO_ARGS@ +POPPLER_0_20_OR_LATER = @POPPLER_0_20_OR_LATER@ POPPLER_INC = @POPPLER_INC@ # diff -rubB org/nmake.opt new/nmake.opt --- org/nmake.opt 2013-02-11 15:50:52.000000000 -0500 +++ new/nmake.opt 2013-02-11 16:18:59.000000000 -0500 @@ -419,10 +419,12 @@ # Uncomment for PDF support # Uncomment POPPLER_BASE_STREAM_HAS_TWO_ARGS = YES for Poppler >= 0.16.0 +# Uncomment POPPLER_0_20_OR_LATER = YES for Poppler >= 0.20.0 #POPPLER_ENABLED = YES #POPPLER_CFLAGS = -Ie:/kde/include -Ie:/kde/include/poppler #POPPLER_HAS_OPTCONTENT = YES #POPPLER_BASE_STREAM_HAS_TWO_ARGS = YES +#POPPLER_0_20_OR_LATER = YES #POPPLER_LIBS = e:/kde/lib/poppler.lib e:/kde/lib/freetype.lib e:/kde/lib/liblcms-1.lib advapi32.lib gdi32.lib # Uncomment for LZMA TIFF support