Skip to content

Commit

Permalink
PDFBOX-5892: add check that /P points to the correct parent
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1921648 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Oct 29, 2024
1 parent 2db4ac2 commit d1964cd
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.pdfbox.pdmodel.common.PDNameTreeNode;
import org.apache.pdfbox.pdmodel.common.PDNumberTreeNode;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureNode;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureTreeRoot;
import org.apache.pdfbox.pdmodel.interactive.action.PDActionGoTo;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
Expand Down Expand Up @@ -884,6 +885,17 @@ else if (base instanceof COSDictionary)
if (kdict.containsKey(COSName.K))
{
checkElement(pageTree, kdict.getDictionaryObject(COSName.K));

// Check that the /P entry points to the correct object
PDStructureNode node = PDStructureNode.create(kdict);
for (Object obj : node.getKids())
{
if (obj instanceof PDStructureElement)
{
PDStructureNode parent = ((PDStructureElement) obj).getParent();
assertTrue(parent.getCOSObject() == kdict);
}
}
return;
}

Expand Down

0 comments on commit d1964cd

Please sign in to comment.