From 1e155afdbe22d9ee6700f3323e0894ee402b7816 Mon Sep 17 00:00:00 2001 From: Tilman Hausherr Date: Thu, 4 Jul 2024 08:24:54 +0000 Subject: [PATCH] PDFBOX-5848: remove /Parent entry for widgets because it can lead to orphan pages git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1918903 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/pdfbox/multipdf/Splitter.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Splitter.java b/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Splitter.java index cbbb6139fa8..b2ff778cec6 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Splitter.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Splitter.java @@ -57,6 +57,7 @@ import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationPopup; +import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream; import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDDestination; import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDNamedDestination; @@ -820,6 +821,12 @@ private void processAnnotations(PDPage imported) throws IOException } } } + if (annotationClone instanceof PDAnnotationWidget && + annotationClone.getCOSObject().containsKey(COSName.PARENT)) + { + // remove non-terminal field /Parent reference, because this may lead to orphan pages + annotationClone.getCOSObject().removeItem(COSName.PARENT); + } if (annotation.getPage() != null) { annotationClone.setPage(imported);