diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java b/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java index 31b9a341bc6..fa3f9414dac 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java @@ -1320,8 +1320,13 @@ private Map bfSearchForObjects() throws IOException if (lastObjOffset > 0) { // add the former object ID only if there was a subsequent object ID - bfCOSObjectKeyOffsets.put( - new COSObjectKey(lastObjectId, lastGenID), lastObjOffset); + COSObjectKey objectKey = new COSObjectKey(lastObjectId, lastGenID); + if(!bfCOSObjectKeyOffsets.containsKey(objectKey)) { + bfCOSObjectKeyOffsets.put(objectKey, lastObjOffset); + } else { + LOG.debug("Ignoring duplicate object key (" + objectKey + + ")"); + } } lastObjectId = objectId; lastGenID = genID;