pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1608184 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
Date Sun, 06 Jul 2014 11:18:27 GMT
Author: tilman
Date: Sun Jul  6 11:18:26 2014
New Revision: 1608184

URL: http://svn.apache.org/r1608184
Log:
PDFBOX-2183: return null if annotation rectangle isn't a rectangle array; minor cleanup

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java?rev=1608184&r1=1608183&r2=1608184&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
Sun Jul  6 11:18:26 2014
@@ -24,6 +24,7 @@ import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
@@ -79,7 +80,7 @@ public abstract class PDAnnotation imple
      */
     public static final int FLAG_TOGGLE_NO_VIEW = 1 << 8;
 
-    private COSDictionary dictionary;
+    private final COSDictionary dictionary;
 
     /**
      * Create the correct annotation from the base COS object.
@@ -206,7 +207,18 @@ public abstract class PDAnnotation imple
         PDRectangle rectangle = null;
         if (rectArray != null)
         {
-            rectangle = new PDRectangle(rectArray);
+            if (rectArray.size() == 4
+                    && rectArray.get(0) instanceof COSNumber
+                    && rectArray.get(1) instanceof COSNumber
+                    && rectArray.get(2) instanceof COSNumber
+                    && rectArray.get(3) instanceof COSNumber)
+            {
+                rectangle = new PDRectangle(rectArray);
+            }
+            else
+            {
+                LOG.warn(rectArray + " is not a rectangle array, returning null");
+            }
         }
         return rectangle;
     }
@@ -246,6 +258,7 @@ public abstract class PDAnnotation imple
      * 
      * @return This object as a standard COS object.
      */
+    @Override
     public COSBase getCOSObject()
     {
         return getDictionary();



Mime
View raw message