Skip to content

Commit 8d8626e

Browse files
committed
PDFBOX-6009: drop OBJR and MCR dictionaries if no /Pg entry in itself or in parent
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1925783 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3a7d1e1 commit 8d8626e

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

pdfbox/src/main/java/org/apache/pdfbox/multipdf/Splitter.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,15 @@ private COSBase createDictionaryClone(COSBase src, COSBase dstParent, COSDiction
441441
}
442442
}
443443

444+
// special handling for MCR items ("marked-content reference dictionary")
445+
COSName type = srcDict.getCOSName(COSName.TYPE);
446+
if (COSName.MCR.equals(type) && dstPageDict == null &&
447+
dstParent instanceof COSDictionary && ((COSDictionary) dstParent).getCOSDictionary(COSName.PG) == null)
448+
{
449+
// PAC: Pg entry of marked-content reference and of parent structure is null
450+
return null;
451+
}
452+
444453
// Create and fill clone
445454
dstDict = new COSDictionary();
446455
structDictMap.put(srcDict, dstDict);
@@ -457,7 +466,6 @@ private COSBase createDictionaryClone(COSBase src, COSBase dstParent, COSDiction
457466

458467
// special handling for OBJR items ("object reference dictionary")
459468
// see e.g. file 488300.pdf and Root/StructTreeRoot/K/K/[2]/K/[1]/K/[0]/Obj
460-
COSName type = srcDict.getCOSName(COSName.TYPE);
461469
if (COSName.OBJR.equals(type))
462470
{
463471
COSDictionary srcObj = srcDict.getCOSDictionary(COSName.OBJ);
@@ -475,6 +483,12 @@ else if (srcObj != null) // 079177.pdf
475483
{
476484
return null;
477485
}
486+
if (dstPageDict == null &&
487+
dstParent instanceof COSDictionary && ((COSDictionary) dstParent).getCOSDictionary(COSName.PG) == null)
488+
{
489+
// Pg entry of object reference dictionary and of parent structure is null
490+
return null;
491+
}
478492
}
479493
else
480494
{

0 commit comments

Comments
 (0)