Skip to content

Commit

Permalink
PDFBOX-5848: remove /Parent entry for widgets because it can lead to …
Browse files Browse the repository at this point in the history
…orphan pages

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1918903 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Jul 4, 2024
1 parent 2b20d5f commit 1e155af
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pdfbox/src/main/java/org/apache/pdfbox/multipdf/Splitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1e155af

Please sign in to comment.