From 0ba8d7d8f81de6aee3735ebbc921161db9c918c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Lehmk=C3=BChler?= Date: Mon, 27 Jan 2014 18:39:41 +0000 Subject: [PATCH] PDFBOX-1865: take the length of the stream into account when comparing xobjects git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1561782 13f79535-47bb-0310-9956-ffa450edef68 --- .../pdmodel/graphics/xobject/PDXObjectForm.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java index 7862b722a91..0bfc2ff846b 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java @@ -126,8 +126,18 @@ public PDResources getResources() Map xobjects = retval.getXObjects(); if (xobjects != null && xobjects.containsKey(name)) { - retval.removeXObject(name); - LOG.debug("Removed XObjectForm "+name+" to avoid a recursion"); + PDXObject xobject = xobjects.get(name); + if (xobject instanceof PDXObjectForm) + { + int length1 = getCOSStream().getInt(COSName.LENGTH); + int length2 = xobject.getCOSStream().getInt(COSName.LENGTH); + // seems to be the same object + if (length1 == length2) + { + retval.removeXObject(name); + LOG.debug("Removed XObjectForm "+name+" to avoid a recursion"); + } + } } } }