From 4dba481fe898c6317696d50b109f5aed8f269c19 Mon Sep 17 00:00:00 2001
From: mike kowalski <michal_kowalski@hotmail.com>
Date: Sun, 12 Oct 2025 10:04:22 -0700
Subject: [PATCH] Replace getLength() with size() on a GooString (Poppler)

GooString in poppler no longer defines getLength() method.
Call size() from base string directly.

(cherry picked from commit ace884e13e413b0cc49ece80936584ef92c986f5)
---
 src/extension/internal/pdfinput/pdf-parser.cpp    | 4 ++--
 src/extension/internal/pdfinput/poppler-utils.cpp | 6 +++---
 src/extension/internal/pdfinput/poppler-utils.h   | 9 +++++++++
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index 0d62c20875..ba6c448513 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -2256,7 +2256,7 @@ void PdfParser::doShowText(GooString *s) {
     auto font = state->getFont();
     int wMode = font->getWMode(); // Vertical/Horizontal/Invalid
 
-    builder->beginString(state, s->getLength());
+    builder->beginString(state, get_goostring_length(*s));
 
     // handle a Type 3 char
     if (font->getType() == fontType3) {
@@ -2267,7 +2267,7 @@ void PdfParser::doShowText(GooString *s) {
     state->textTransformDelta(0, state->getRise(), &riseX, &riseY);
 
     auto p = s->getCString(); // char* or const char*
-    int len = s->getLength();
+    int len = get_goostring_length(*s);
 
     while (len > 0) {
 
diff --git a/src/extension/internal/pdfinput/poppler-utils.cpp b/src/extension/internal/pdfinput/poppler-utils.cpp
index 8110a3e085..cef753dab8 100644
--- a/src/extension/internal/pdfinput/poppler-utils.cpp
+++ b/src/extension/internal/pdfinput/poppler-utils.cpp
@@ -168,7 +168,7 @@ void InkFontDict::hashFontObject1(const Object *obj, FNVHash *h)
         case objString:
             h->hash('s');
             s = obj->getString();
-            h->hash(s->c_str(), s->getLength());
+            h->hash(s->c_str(), get_goostring_length(*s));
             break;
         case objName:
             h->hash('n');
@@ -586,10 +586,10 @@ std::string getDictString(Dict *dict, const char *key)
 std::string getString(const GooString *value)
 {
     if (_POPPLER_HAS_UNICODE_BOM(value)) {
-        return g_convert(value->getCString () + 2, value->getLength () - 2,
+        return g_convert(value->getCString () + 2, get_goostring_length(*value) - 2,
                          "UTF-8", "UTF-16BE", NULL, NULL, NULL);
     } else if (_POPPLER_HAS_UNICODE_BOMLE(value)) {
-        return g_convert(value->getCString () + 2, value->getLength () - 2,
+        return g_convert(value->getCString () + 2, get_goostring_length(*value) - 2,
                          "UTF-8", "UTF-16LE", NULL, NULL, NULL);
     }
     return value->toStr();
diff --git a/src/extension/internal/pdfinput/poppler-utils.h b/src/extension/internal/pdfinput/poppler-utils.h
index e51d6a9da3..15b5ed81e7 100644
--- a/src/extension/internal/pdfinput/poppler-utils.h
+++ b/src/extension/internal/pdfinput/poppler-utils.h
@@ -19,6 +19,7 @@
 #include <string>
 #include <unordered_set>
 #include <vector>
+#include <goo/GooString.h>
 
 #include "poppler-transition-api.h"
 
@@ -104,4 +105,12 @@ private:
     void hashFontObject1(const Object *obj, FNVHash *h);
 };
 
+inline size_t get_goostring_length(const GooString& str) {
+#if POPPLER_CHECK_VERSION(25, 10, 0)
+    return str.size();
+#else
+    return str.getLength();
+#endif
+}
+
 #endif /* POPPLER_UTILS_H */
-- 
GitLab

