]> git.pld-linux.org Git - packages/gdal.git/blob - gdal-poppler.patch
243c4ce5a04dd38f42c0dfdda78f85b69e39d8a5
[packages/gdal.git] / gdal-poppler.patch
1 From 17e98757e78969a199d1d6318f53d088da192191 Mon Sep 17 00:00:00 2001
2 From: Even Rouault <even.rouault@spatialys.com>
3 Date: Fri, 18 Feb 2022 22:47:01 +0100
4 Subject: [PATCH] PDF: fix build against Poppler > 22.2
5
6 ---
7  frmts/pdf/pdfdataset.cpp | 17 +++++++++++------
8  1 file changed, 11 insertions(+), 6 deletions(-)
9
10 diff --git a/frmts/pdf/pdfdataset.cpp b/frmts/pdf/pdfdataset.cpp
11 index 22238bd74822..08f8e31c86a7 100644
12 --- a/frmts/pdf/pdfdataset.cpp
13 +++ b/frmts/pdf/pdfdataset.cpp
14 @@ -4101,8 +4101,6 @@ PDFDataset *PDFDataset::Open( GDALOpenIn
15  #ifdef HAVE_POPPLER
16    if(bUseLib.test(PDFLIB_POPPLER))
17    {
18 -    GooString* poUserPwd = nullptr;
19 -
20      /* Set custom error handler for poppler errors */
21  #if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 85
22      setErrorCallback(PDFDatasetErrorFunction);
23 @@ -4136,8 +4134,6 @@ PDFDataset *PDFDataset::Open( GDALOpenIn
24      while( true )
25      {
26          VSIFSeekL(fp, 0, SEEK_SET);
27 -        if (pszUserPwd)
28 -            poUserPwd = new GooString(pszUserPwd);
29  
30  #if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
31          auto poStream = new VSIPDFFileStream(fp, pszFilename, std::move(oObj));
32 @@ -4145,8 +4141,18 @@ PDFDataset *PDFDataset::Open( GDALOpenIn
33          oObj.getObj()->initNull();
34          auto poStream = new VSIPDFFileStream(fp, pszFilename, oObj.getObj());
35  #endif
36 +#if POPPLER_MAJOR_VERSION > 22 || (POPPLER_MAJOR_VERSION == 22 && POPPLER_MINOR_VERSION > 2)
37 +        std::optional<GooString> osUserPwd;
38 +        if (pszUserPwd)
39 +            osUserPwd = std::optional<GooString>(pszUserPwd);
40 +        poDocPoppler = new PDFDoc(poStream, std::optional<GooString>(), osUserPwd);
41 +#else
42 +        GooString* poUserPwd = nullptr;
43 +        if (pszUserPwd)
44 +            poUserPwd = new GooString(pszUserPwd);
45          poDocPoppler = new PDFDoc(poStream, nullptr, poUserPwd);
46          delete poUserPwd;
47 +#endif
48  
49          if ( !poDocPoppler->isOk() || poDocPoppler->getNumPages() == 0 )
50          {
51 --- gdal-3.0.4/frmts/pdf/pdfdataset.cpp.orig    2022-04-15 17:08:03.072819386 +0200
52 +++ gdal-3.0.4/frmts/pdf/pdfdataset.cpp 2022-04-15 17:43:26.613241927 +0200
53 @@ -4837,7 +4837,11 @@ PDFDataset *PDFDataset::Open( GDALOpenIn
54  #ifdef HAVE_POPPLER
55    if (bUseLib.test(PDFLIB_POPPLER))
56    {
57 +#if POPPLER_MAJOR_VERSION > 22 || (POPPLER_MAJOR_VERSION == 22 && POPPLER_MINOR_VERSION > 3)
58 +    std::unique_ptr<GooString> poMetadata = poCatalogPoppler->readMetadata();
59 +#else
60      GooString* poMetadata = poCatalogPoppler->readMetadata();
61 +#endif
62      if (poMetadata)
63      {
64  #if (POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 72)
65 @@ -4851,7 +4855,9 @@ PDFDataset *PDFDataset::Open( GDALOpenIn
66              const char * const apszMDList[2] = { pszContent, nullptr };
67              poDS->SetMetadata(const_cast<char**>(apszMDList), "xml:XMP");
68          }
69 +#if POPPLER_MAJOR_VERSION < 22 || (POPPLER_MAJOR_VERSION == 22 && POPPLER_MINOR_VERSION < 4)
70          delete poMetadata;
71 +#endif
72      }
73  
74      /* Read Info object */
This page took 0.0691 seconds and 4 git commands to generate.