pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1857158 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
Date Tue, 09 Apr 2019 10:17:55 GMT
Author: tilman
Date: Tue Apr  9 10:17:55 2019
New Revision: 1857158

URL: http://svn.apache.org/viewvc?rev=1857158&view=rev
Log:
PDFBOX-4509: check for indirect fonts too

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java?rev=1857158&r1=1857157&r2=1857158&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java Tue
Apr  9 10:17:55 2019
@@ -707,6 +707,22 @@ public final class PDResources implement
             return dict.getKeyForValue(object.getCOSObject());
         }
 
+        // PDFBOX-4509: It could exist as an indirect object, happens when a font is taken
from the 
+        // AcroForm default resources of a loaded PDF.
+        if (dict != null && COSName.FONT.equals(kind))
+        {
+            for (Map.Entry<COSName, COSBase> entry : dict.entrySet())
+            {
+                if (entry.getValue() instanceof COSObject)
+                {
+                    if (object.getCOSObject() == ((COSObject) entry.getValue()).getObject())
+                    {
+                        return entry.getKey();
+                    }
+                }
+            }
+        }
+
         // add the item with a new key
         COSName name = createKey(kind, prefix);
         put(kind, name, object);



Mime
View raw message