This commit is contained in:
Kellermorph
2026-08-20 11:21:22 +02:00
parent 1780fde458
commit b8df298953
+10 -6
View File
@@ -492,13 +492,17 @@ void convertComponentInfoAnnotations(const QString &pdfPath,
QByteArray contents = annotations[annotIndex].contents.toUtf8(); QByteArray contents = annotations[annotIndex].contents.toUtf8();
// Replace /Subtype /Link with /Subtype /Text, bounded to current object. // Replace /Subtype /Link with /Subtype /Text, bounded to the enclosing
// Search only the bytes we just appended (the current annotation header). // PDF object. Anchoring to " 0 obj" prevents hitting /Subtype /Link
int searchStart = out.size() - (aDictOpen - pos); // from a cross-ref annotation that sits between the previous marker
int subTypePos = out.indexOf("/Subtype /Link", searchStart); // and the current annotation on the same page.
if (subTypePos != -1) { int objStart = body.lastIndexOf(" 0 obj", aDictOpen);
int subTypeInBody = (objStart != -1)
? body.indexOf("/Subtype /Link", objStart) : -1;
int subTypePos = (subTypeInBody != -1 && subTypeInBody < aDictOpen)
? out.size() - (aDictOpen - subTypeInBody) : -1;
if (subTypePos != -1)
out.replace(subTypePos, 14, "/Subtype /Text"); out.replace(subTypePos, 14, "/Subtype /Text");
}
// Encode as UTF-16BE hex with BOM for proper Unicode support (Umlauten etc.). // Encode as UTF-16BE hex with BOM for proper Unicode support (Umlauten etc.).
// PDF spec: hex strings starting with FE FF are interpreted as UTF-16BE. // PDF spec: hex strings starting with FE FF are interpreted as UTF-16BE.