pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1777017 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
Date Mon, 02 Jan 2017 20:57:29 GMT
Author: msahyoun
Date: Mon Jan  2 20:57:28 2017
New Revision: 1777017

URL: http://svn.apache.org/viewvc?rev=1777017&view=rev
Log:
PDFBOX-3642: test for PDImageXObject to avoid ClassCastException

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java?rev=1777017&r1=1777016&r2=1777017&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
Mon Jan  2 20:57:28 2017
@@ -44,6 +44,7 @@ import org.apache.pdfbox.pdmodel.fdf.FDF
 import org.apache.pdfbox.pdmodel.fdf.FDFDictionary;
 import org.apache.pdfbox.pdmodel.fdf.FDFDocument;
 import org.apache.pdfbox.pdmodel.fdf.FDFField;
+import org.apache.pdfbox.pdmodel.graphics.PDXObject;
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget;
@@ -709,7 +710,7 @@ public final class PDAcroForm implements
      */
     private boolean resolveNeedsTranslation(PDAppearanceStream appearanceStream)
     {
-boolean needsTranslation = false;
+        boolean needsTranslation = false;
         
         PDResources resources = appearanceStream.getResources();
         if (resources != null && resources.getXObjectNames().iterator().hasNext())
@@ -723,13 +724,16 @@ boolean needsTranslation = false;
                 {
                     // if the BBox of the PDFormXObject does not start at 0,0
                     // there is no need do translate as this is done by the BBox definition.
-                    PDFormXObject xObject = (PDFormXObject) resources.getXObject(xObjectNames.next());
-                    PDRectangle bbox = xObject.getBBox();
-                    float llX = bbox.getLowerLeftX();
-                    float llY = bbox.getLowerLeftY();
-                    if (llX == 0 && llY == 0)
+                    PDXObject xObject = resources.getXObject(xObjectNames.next());
+                    if (xObject instanceof PDFormXObject)
                     {
-                        needsTranslation = true;
+                        PDRectangle bbox = ((PDFormXObject)xObject).getBBox();
+                        float llX = bbox.getLowerLeftX();
+                        float llY = bbox.getLowerLeftY();
+                        if (llX == 0 && llY == 0)
+                        {
+                            needsTranslation = true;
+                        }
                     }
                 }
                 catch (IOException e)



Mime
View raw message