summaryrefslogtreecommitdiff
blob: 90ee94d062169cb8df433e1e12748b9f6511f3e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Description: Add support for Poppler 0.71.0.
Author: Even Rouault <even.rouault@spatialys.com>
Origin: https://github.com/OSGeo/gdal/commit/4cc0215b8f2cef3582265cdfaf16589390697706
Bug: https://github.com/OSGeo/gdal/issues/1121
Bug-Debian: https://bugs.debian.org/915722

--- a/frmts/pdf/pdfdataset.cpp
+++ b/frmts/pdf/pdfdataset.cpp
@@ -2593,18 +2593,25 @@ static void PDFDatasetErrorFunctionCommo
 }
 
 #ifdef POPPLER_0_20_OR_LATER
-static void PDFDatasetErrorFunction(CPL_UNUSED void* userData, CPL_UNUSED ErrorCategory eErrCategory,
+
+static void PDFDatasetErrorFunction(void* /* userData*/,
+                                    ErrorCategory /* eErrCategory */,
 #ifdef POPPLER_0_23_OR_LATER
                                     Goffset nPos,
 #else
                                     int nPos,
 #endif
-                                    char *pszMsg)
+#ifdef POPPLER_0_71_OR_LATER
+                                    const char *pszMsg
+#else
+                                    char *pszMsg
+#endif
+                                   )
 {
     CPLString osError;
 
     if (nPos >= 0)
-        osError.Printf("Pos = %d, ", (int)nPos);
+        osError.Printf("Pos = " CPL_FRMT_GUIB ", ", static_cast<GUIntBig>(nPos));
     osError += pszMsg;
     PDFDatasetErrorFunctionCommon(osError);
 }
@@ -4442,7 +4449,7 @@ GDALDataset *PDFDataset::Open( GDALOpenI
 #ifdef HAVE_POPPLER
     if (bUseLib.test(PDFLIB_POPPLER))
     {
-        PDFRectangle* psMediaBox = poPagePoppler->getMediaBox();
+        const auto* psMediaBox = poPagePoppler->getMediaBox();
         dfX1 = psMediaBox->x1;
         dfY1 = psMediaBox->y1;
         dfX2 = psMediaBox->x2;
@@ -4780,14 +4787,12 @@ GDALDataset *PDFDataset::Open( GDALOpenI
     GooString* poMetadata = poCatalogPoppler->readMetadata();
     if (poMetadata)
     {
-        char* pszContent = poMetadata->getCString();
+        const char* pszContent = poMetadata->getCString();
         if (pszContent != nullptr &&
             STARTS_WITH(pszContent, "<?xpacket begin="))
         {
-            char *apszMDList[2];
-            apszMDList[0] = pszContent;
-            apszMDList[1] = nullptr;
-            poDS->SetMetadata(apszMDList, "xml:XMP");
+            const char * const apszMDList[2] = { pszContent, nullptr };
+            poDS->SetMetadata(const_cast<char**>(apszMDList), "xml:XMP");
         }
         delete poMetadata;
     }
--- a/frmts/pdf/pdfio.h
+++ b/frmts/pdf/pdfio.h
@@ -58,6 +58,15 @@
 #define makeSubStream_object_type Object*
 #endif
 
+// Detect Poppler 0.71 that no longer defines GBool
+#ifdef POPPLER_0_69_OR_LATER
+#ifndef initObj
+#define POPPLER_0_71_OR_LATER
+#define GBool bool
+#define gFalse false
+#endif
+#endif
+
 class VSIPDFFileStream: public BaseStream
 {
     public: