Skip to content

Commit 3a7d1e1

Browse files
committed
PDFBOX-6009: improve tests, make sure that MCR and OBJR dictionaries have a /Pg entry itself or in the parent
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1925782 13f79535-47bb-0310-9956-ffa450edef68
1 parent 383c82e commit 3a7d1e1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,9 @@ private void checkForPageOrphans(PDDocument doc) throws IOException
858858
// StructTreeRoot/IDTree trees.
859859
PDPageTree pageTree = doc.getPages();
860860
PDStructureTreeRoot structureTreeRoot = doc.getDocumentCatalog().getStructureTreeRoot();
861-
checkElement(pageTree, structureTreeRoot.getParentTree().getCOSObject());
861+
checkElement(pageTree, structureTreeRoot.getParentTree().getCOSObject(), structureTreeRoot.getCOSObject());
862862
assertNotNull(structureTreeRoot.getK());
863-
checkElement(pageTree, structureTreeRoot.getK());
863+
checkElement(pageTree, structureTreeRoot.getK(), structureTreeRoot.getCOSObject());
864864
checkForIDTreeOrphans(pageTree, structureTreeRoot);
865865
}
866866

@@ -881,7 +881,7 @@ private void checkForIDTreeOrphans(PDPageTree pageTree, PDStructureTreeRoot stru
881881
}
882882
if (!element.getKids().isEmpty())
883883
{
884-
checkElement(pageTree, element.getCOSObject().getDictionaryObject(COSName.K));
884+
checkElement(pageTree, element.getCOSObject().getDictionaryObject(COSName.K), element.getCOSObject());
885885
}
886886
}
887887
}
@@ -936,7 +936,7 @@ else if (base instanceof COSDictionary)
936936
// See PDF specification Table 325 – Entries in an object reference dictionary
937937
// example of file with /Kids: 000153.pdf 000208.pdf 000314.pdf 000359.pdf 000671.pdf
938938
// from digitalcorpora site
939-
private void checkElement(PDPageTree pageTree, COSBase base) throws IOException
939+
private void checkElement(PDPageTree pageTree, COSBase base, COSDictionary parentDict) throws IOException
940940
{
941941
if (base instanceof COSArray)
942942
{
@@ -946,7 +946,7 @@ private void checkElement(PDPageTree pageTree, COSBase base) throws IOException
946946
{
947947
base2 = ((COSObject) base2).getObject();
948948
}
949-
checkElement(pageTree, base2);
949+
checkElement(pageTree, base2, parentDict);
950950
}
951951
}
952952
else if (base instanceof COSDictionary)
@@ -959,7 +959,7 @@ else if (base instanceof COSDictionary)
959959
}
960960
if (kdict.containsKey(COSName.K))
961961
{
962-
checkElement(pageTree, kdict.getDictionaryObject(COSName.K));
962+
checkElement(pageTree, kdict.getDictionaryObject(COSName.K), kdict);
963963

964964
// Check that the /P entry points to the correct object
965965
PDStructureNode node = PDStructureNode.create(kdict);
@@ -977,11 +977,11 @@ else if (base instanceof COSDictionary)
977977
// if we're in a number tree, check /Nums and /Kids
978978
if (kdict.containsKey(COSName.KIDS))
979979
{
980-
checkElement(pageTree, kdict.getDictionaryObject(COSName.KIDS));
980+
checkElement(pageTree, kdict.getDictionaryObject(COSName.KIDS), kdict);
981981
}
982982
else if (kdict.containsKey(COSName.NUMS))
983983
{
984-
checkElement(pageTree, kdict.getDictionaryObject(COSName.NUMS));
984+
checkElement(pageTree, kdict.getDictionaryObject(COSName.NUMS), kdict);
985985
}
986986

987987
// if we're an object reference dictionary (/OBJR), check the obj

0 commit comments

Comments
 (0)