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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
Source:
https://build.opensuse.org/projects/graphics/packages/inkscape/files/fix_build_with_poppler_26.07.patch
From eebf0342cbfcd23c6cba6053dd6ab7306d0de065 Mon Sep 17 00:00:00 2001
From: KrIr17 <elendil.krir17@gmail.com>
Date: Sat, 4 Jul 2026 14:07:44 +0200
Subject: [PATCH] Fix building with Poppler 26.07.0
1. `arrayGetfoo()` to `getArray()->getFoo()` [1]
2. `streamGetFoo()` to `getStream()->getFoo()` [2]
3. indextolabel now requires an `std::string *` and not `GooString *`
introduced _POPPLER_STRING_26_7 that changes accordingly.
Relevant poppler commits:
[1] [Remove Object::arrayGetNF](https://gitlab.freedesktop.org/poppler/poppler/-/commit/d9ffc4c29d1975a5c81d6bac9d8a1b6dc5aa1f50): Technically only arrayGetNF was removed, but perusing the commit shows that all `arrayGetFoo` are being changed. I assume they are slated for removal in future releases.
[2] [Remove Object::streamGetDict](gitlab.freedesktop.org/poppler/poppler/-/commit/87edb5a5c40e67e782e54a14a2251547b4acdfb5)
[3] [Use std::string instead of GooString for label](https://gitlab.freedesktop.org/poppler/poppler/-/commit/9e34004aae04064f1b798b5e711e13d0dddacf9e)
(cherry picked from commit 9262f83aff7d8a6cadcb42446f9b943a561910cf)
---
src/extension/internal/pdfinput/pdf-input.cpp | 5 +-
.../internal/pdfinput/pdf-parser.cpp | 50 +++++++++----------
.../pdfinput/poppler-transition-api.h | 6 +++
.../internal/pdfinput/poppler-utils.cpp | 29 ++++++-----
.../internal/pdfinput/poppler-utils.h | 1 +
5 files changed, 52 insertions(+), 39 deletions(-)
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 441871bb10..3507ce4173 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -855,9 +855,10 @@ PdfInput::add_builder_page(std::shared_ptr<PDFDoc>pdf_doc, SvgBuilder *builder,
// Parse the annotations
if (auto annots = page->getAnnotsObject(); annots.isArray()) {
- auto const size = annots.arrayGetLength();
+ auto* annotsArray = annots.getArray();
+ auto const size = annotsArray->getLength();
for (int i = 0; i < size; i++) {
- pdf_parser.build_annots(annots.arrayGet(i), page_num);
+ pdf_parser.build_annots(annotsArray->get(i), page_num);
}
}
}
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index e32fa24b32..bf8daaac1b 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -293,8 +293,8 @@ PdfParser::PdfParser(std::shared_ptr<PDFDoc> pdf_doc, Inkscape::Extension::Inter
if (page) {
// Increment the page building here and set page label
Catalog *catalog = pdf_doc->getCatalog();
- GooString *label = new GooString("");
- catalog->indexToLabel(page->getNum() - 1, label);
+ _POPPLER_STRING_26_7 label;
+ catalog->indexToLabel(page->getNum() - 1, &label);
builder->pushPage(getString(label), state);
}
@@ -370,8 +370,8 @@ void PdfParser::parse(Object *obj, GBool topLevel) {
Object obj2;
if (obj->isArray()) {
- for (int i = 0; i < obj->arrayGetLength(); ++i) {
- _POPPLER_CALL_ARGS(obj2, obj->arrayGet, i);
+ for (int i = 0; i < obj->getArray()->getLength(); ++i) {
+ _POPPLER_CALL_ARGS(obj2, obj->getArray()->get, i);
if (!obj2.isStream()) {
error(errInternal, -1, "Weird page contents");
_POPPLER_FREE(obj2);
@@ -808,8 +808,8 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
for (int &i : backdropColor.c) {
i = 0;
}
- for (int i = 0; i < obj3.arrayGetLength() && i < gfxColorMaxComps; ++i) {
- _POPPLER_CALL_ARGS(obj4, obj3.arrayGet, i);
+ for (int i = 0; i < obj3.getArray()->getLength() && i < gfxColorMaxComps; ++i) {
+ _POPPLER_CALL_ARGS(obj4, obj3.getArray()->get, i);
if (obj4.isNum()) {
backdropColor.c[i] = dblToCol(obj4.getNum());
}
@@ -818,7 +818,7 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
}
_POPPLER_FREE(obj3);
if (_POPPLER_CALL_ARGS_DEREF(obj3, obj2.dictLookup, "G").isStream()) {
- if (_POPPLER_CALL_ARGS_DEREF(obj4, obj3.streamGetDict()->lookup, "Group").isDict()) {
+ if (_POPPLER_CALL_ARGS_DEREF(obj4, obj3.getStream()->getDict()->lookup, "Group").isDict()) {
std::unique_ptr<GfxColorSpace> blendingColorSpace;
GBool isolated = gFalse;
GBool knockout = gFalse;
@@ -881,7 +881,7 @@ void PdfParser::doSoftMask(Object *str, GBool alpha,
}
// get stream dict
- dict = str->streamGetDict();
+ dict = str->getStream()->getDict();
// check form type
_POPPLER_CALL_ARGS(obj1, dict->lookup, "FormType");
@@ -898,7 +898,7 @@ void PdfParser::doSoftMask(Object *str, GBool alpha,
return;
}
for (i = 0; i < 4; ++i) {
- _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, i);
+ _POPPLER_CALL_ARGS(obj2, obj1.getArray()->get, i);
bbox[i] = obj2.getNum();
_POPPLER_FREE(obj2);
}
@@ -908,7 +908,7 @@ void PdfParser::doSoftMask(Object *str, GBool alpha,
_POPPLER_CALL_ARGS(obj1, dict->lookup, "Matrix");
if (obj1.isArray()) {
for (i = 0; i < 6; ++i) {
- _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, i);
+ _POPPLER_CALL_ARGS(obj2, obj1.getArray()->get, i);
m[i] = obj2.getNum();
_POPPLER_FREE(obj2);
}
@@ -2378,7 +2378,7 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
}
//add layer at root if xObject has type OCG
- _POPPLER_CALL_ARGS(obj2, obj1.streamGetDict()->lookup, "OC");
+ _POPPLER_CALL_ARGS(obj2, obj1.getStream()->getDict()->lookup, "OC");
if(obj2.isDict()){
auto type_dict = obj2.getDict();
if (type_dict->lookup("Type").isName("OCG")) {
@@ -2396,7 +2396,7 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
}
}
- _POPPLER_CALL_ARGS(obj2, obj1.streamGetDict()->lookup, "Subtype");
+ _POPPLER_CALL_ARGS(obj2, obj1.getStream()->getDict()->lookup, "Subtype");
if (obj2.isName(const_cast<char*>("Image"))) {
_POPPLER_CALL_ARGS(refObj, res->lookupXObjectNF, name);
doImage(&refObj, obj1.getStream(), gFalse);
@@ -2404,7 +2404,7 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
} else if (obj2.isName(const_cast<char*>("Form"))) {
doForm(&obj1);
} else if (obj2.isName(const_cast<char*>("PS"))) {
- _POPPLER_CALL_ARGS(obj3, obj1.streamGetDict()->lookup, "Level1");
+ _POPPLER_CALL_ARGS(obj3, obj1.getStream()->getDict()->lookup, "Level1");
} else if (obj2.isName()) {
error(errSyntaxError, getPos(), "Unknown XObject subtype '{0:s}'", obj2.getName());
} else {
@@ -2535,7 +2535,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
_POPPLER_CALL_ARGS(obj1, dict->lookup, "D");
}
if (obj1.isArray()) {
- _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, 0);
+ _POPPLER_CALL_ARGS(obj2, obj1.getArray()->get, 0);
if (obj2.isInt() && obj2.getInt() == 1) {
invert = gTrue;
}
@@ -2597,7 +2597,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
goto err1;
}
maskStr = smaskObj.getStream();
- maskDict = smaskObj.streamGetDict();
+ maskDict = smaskObj.getStream()->getDict();
_POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Width");
if (obj1.isNull()) {
_POPPLER_FREE(obj1);
@@ -2663,8 +2663,8 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
} else if (maskObj.isArray()) {
// color key mask
int i;
- for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) {
- _POPPLER_CALL_ARGS(obj1, maskObj.arrayGet, i);
+ for (i = 0; i < maskObj.getArray()->getLength() && i < 2*gfxColorMaxComps; ++i) {
+ _POPPLER_CALL_ARGS(obj1, maskObj.getArray()->get, i);
maskColors[i] = obj1.getInt();
_POPPLER_FREE(obj1);
}
@@ -2675,7 +2675,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
goto err1;
}
maskStr = maskObj.getStream();
- maskDict = maskObj.streamGetDict();
+ maskDict = maskObj.getStream()->getDict();
_POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Width");
if (obj1.isNull()) {
_POPPLER_FREE(obj1);
@@ -2722,7 +2722,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
_POPPLER_CALL_ARGS(obj1, maskDict->lookup, "D");
}
if (obj1.isArray()) {
- _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, 0);
+ _POPPLER_CALL_ARGS(obj2, obj1.getArray()->get, 0);
if (obj2.isInt() && obj2.getInt() == 1) {
maskInvert = gTrue;
}
@@ -2775,7 +2775,7 @@ void PdfParser::doForm(Object *str, double *offset)
}
// get stream dict
- dict = str->streamGetDict();
+ dict = str->getStream()->getDict();
// check form type
_POPPLER_CALL_ARGS(obj1, dict->lookup, "FormType");
@@ -2792,7 +2792,7 @@ void PdfParser::doForm(Object *str, double *offset)
return;
}
for (i = 0; i < 4; ++i) {
- _POPPLER_CALL_ARGS(obj1, bboxObj.arrayGet, i);
+ _POPPLER_CALL_ARGS(obj1, bboxObj.getArray()->get, i);
bbox[i] = obj1.getNum();
_POPPLER_FREE(obj1);
}
@@ -2802,7 +2802,7 @@ void PdfParser::doForm(Object *str, double *offset)
_POPPLER_CALL_ARGS(matrixObj, dict->lookup, "Matrix");
if (matrixObj.isArray()) {
for (i = 0; i < 6; ++i) {
- _POPPLER_CALL_ARGS(obj1, matrixObj.arrayGet, i);
+ _POPPLER_CALL_ARGS(obj1, matrixObj.getArray()->get, i);
m[i] = obj1.getNum();
_POPPLER_FREE(obj1);
}
@@ -3194,10 +3194,10 @@ void PdfParser::loadColorProfile()
return;
Object outputIntents = catDict.dictLookup("OutputIntents");
- if (!outputIntents.isArray() || outputIntents.arrayGetLength() != 1)
+ if (!outputIntents.isArray() || outputIntents.getArray()->getLength() != 1)
return;
- Object firstElement = outputIntents.arrayGet(0);
+ Object firstElement = outputIntents.getArray()->get(0);
if (!firstElement.isDict())
return;
@@ -3245,7 +3245,7 @@ void PdfParser::build_annots(const Object &annot, int page_num)
_POPPLER_CALL_ARGS(Rect_obj, annot_dict->lookup, "Rect");
if (Rect_obj.isArray()) {
for (int i = 0; i < 2; i++) {
- _POPPLER_CALL_ARGS(xy_obj, Rect_obj.arrayGet, i);
+ _POPPLER_CALL_ARGS(xy_obj, Rect_obj.getArray()->get, i);
offset[i] = xy_obj.getNum();
}
doForm(&first_state_obj, offset);
diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
index bf42f54142..058c91f379 100644
--- a/src/extension/internal/pdfinput/poppler-transition-api.h
+++ b/src/extension/internal/pdfinput/poppler-transition-api.h
@@ -15,6 +15,12 @@
#include <glib/poppler-features.h>
#include <poppler/UTF.h>
+#if POPPLER_CHECK_VERSION(26, 7, 0)
+#define _POPPLER_STRING_26_7 std::string
+#else
+#define _POPPLER_STRING_26_7 GooString
+#endif
+
#if POPPLER_CHECK_VERSION(26, 6, 0)
#define _POPPLER_GET_GRAY(color, gray) getGray(color, gray)
#define _POPPLER_GET_RGB(color, rgb) getRGB(color, rgb)
diff --git a/src/extension/internal/pdfinput/poppler-utils.cpp b/src/extension/internal/pdfinput/poppler-utils.cpp
index 902736281a..d084d9218a 100644
--- a/src/extension/internal/pdfinput/poppler-utils.cpp
+++ b/src/extension/internal/pdfinput/poppler-utils.cpp
@@ -186,15 +186,16 @@ void InkFontDict::hashFontObject1(const Object *obj, FNVHash *h)
case objNull:
h->hash('z');
break;
- case objArray:
- h->hash('a');
- n = obj->arrayGetLength();
- h->hash((char *)&n, sizeof(int));
- for (i = 0; i < n; ++i) {
- const Object &obj2 = obj->arrayGetNF(i);
- hashFontObject1(&obj2, h);
- }
- break;
+ case objArray: {
+ h->hash('a');
+ Array * objArray = obj->getArray();
+ n = objArray->getLength();
+ h->hash((char *)&n, sizeof(int));
+ for (i = 0; i < n; ++i) {
+ const Object &obj2 = objArray->getNF(i);
+ hashFontObject1(&obj2, h);
+ }
+ } break;
case objDict: {
h->hash('d');
auto objdict = obj->getDict();
@@ -206,8 +207,7 @@ void InkFontDict::hashFontObject1(const Object *obj, FNVHash *h)
const Object &obj2 = objdict->getValNF(i);
hashFontObject1(&obj2, h);
}
- }
- break;
+ } break;
case objStream:
// this should never happen - streams must be indirect refs
break;
@@ -545,7 +545,7 @@ void _getFontsRecursive(std::shared_ptr<PDFDoc> pdf_doc, Dict *resources, const
continue;
Ref resourcesRef;
- const Object resObj = obj2.streamGetDict()->lookup("Resources", &resourcesRef);
+ const Object resObj = obj2.getStream()->getDict()->lookup("Resources", &resourcesRef);
if (resourcesRef != Ref::INVALID() && !visitedObjects.insert(resourcesRef.num).second)
continue;
@@ -610,6 +610,11 @@ std::string getString(const GooString *value)
return "";
}
+std::string getString(const GooString &value)
+{
+ return getString(value.toStr());
+}
+
/**
* Convert PDF strings, which can be formatted as UTF8, UTF16BE or UTF16LE into
* a predictable UTF8 string consistant with svg requirements.
diff --git a/src/extension/internal/pdfinput/poppler-utils.h b/src/extension/internal/pdfinput/poppler-utils.h
index 13123d79a9..2b1978bf0f 100644
--- a/src/extension/internal/pdfinput/poppler-utils.h
+++ b/src/extension/internal/pdfinput/poppler-utils.h
@@ -86,6 +86,7 @@ std::string getDictString(Dict *dict, const char *key);
std::string getString(const std::string &value);
std::string getString(const std::unique_ptr<GooString> &value);
std::string getString(const GooString *value);
+std::string getString(const GooString &value);
std::string validateString(std::string const &in);
// Replacate poppler FontDict
--
2.54.0
|