pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1686134 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
Date Thu, 18 Jun 2015 02:06:42 GMT
Author: jahewson
Date: Thu Jun 18 02:06:42 2015
New Revision: 1686134

URL: http://svn.apache.org/r1686134
Log:
PDFBOX-2833: Add an API to get the COSObjectKey of a given object

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=1686134&r1=1686133&r2=1686134&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java Thu Jun 18 02:06:42
2015
@@ -241,6 +241,25 @@ public class COSDocument extends COSBase
     }
 
     /**
+     * Returns the COSObjectKey for a given COS object, or null if there is none.
+     * This lookup iterates over all objects in a PDF, which may be slow for large files.
+     * 
+     * @param object COS object
+     * @return key
+     */
+    public COSObjectKey getKey(COSBase object)
+    {
+        for (Map.Entry<COSObjectKey, COSObject> entry : objectPool.entrySet())
+        {
+            if (entry.getValue().getObject() == object)
+            {
+                return entry.getKey();
+            }
+        }
+        return null;
+    }
+    
+    /**
      * This will print contents to stdout.
      */
     public void print()



Mime
View raw message