pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1817423 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java
Date Thu, 07 Dec 2017 21:03:45 GMT
Author: tilman
Date: Thu Dec  7 21:03:45 2017
New Revision: 1817423

URL: http://svn.apache.org/viewvc?rev=1817423&view=rev
Log:
PDFBOX-4027: ignore matrix if not COSArray with 6 elements
PDFBOX-4030: accept indirect objects too

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java?rev=1817423&r1=1817422&r2=1817423&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java
Thu Dec  7 21:03:45 2017
@@ -19,6 +19,7 @@ package org.apache.pdfbox.pdmodel.graphi
 import java.awt.geom.AffineTransform;
 
 import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSFloat;
 import org.apache.pdfbox.cos.COSName;
@@ -43,7 +44,7 @@ public class PDXObjectForm extends PDXOb
     public static final String SUB_TYPE = "Form";
 
     /**
-     * Standard constuctor.
+     * Standard constructor.
      * 
      * @param formStream The XObject is passed as a COSStream.
      */
@@ -154,16 +155,17 @@ public class PDXObjectForm extends PDXOb
     public Matrix getMatrix()
     {
         Matrix retval = null;
-        COSArray array = (COSArray) getCOSStream().getDictionaryObject(COSName.MATRIX);
-        if (array != null)
+        COSBase base = getCOSStream().getDictionaryObject(COSName.MATRIX);
+        if (base instanceof COSArray && ((COSArray) base).size() >= 6)
         {
+            COSArray array = (COSArray) base;
             retval = new Matrix();
-            retval.setValue(0, 0, ((COSNumber) array.get(0)).floatValue());
-            retval.setValue(0, 1, ((COSNumber) array.get(1)).floatValue());
-            retval.setValue(1, 0, ((COSNumber) array.get(2)).floatValue());
-            retval.setValue(1, 1, ((COSNumber) array.get(3)).floatValue());
-            retval.setValue(2, 0, ((COSNumber) array.get(4)).floatValue());
-            retval.setValue(2, 1, ((COSNumber) array.get(5)).floatValue());
+            retval.setValue(0, 0, ((COSNumber) array.getObject(0)).floatValue());
+            retval.setValue(0, 1, ((COSNumber) array.getObject(1)).floatValue());
+            retval.setValue(1, 0, ((COSNumber) array.getObject(2)).floatValue());
+            retval.setValue(1, 1, ((COSNumber) array.getObject(3)).floatValue());
+            retval.setValue(2, 0, ((COSNumber) array.getObject(4)).floatValue());
+            retval.setValue(2, 1, ((COSNumber) array.getObject(5)).floatValue());
         }
         return retval;
     }



Mime
View raw message