pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1865999 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Date Tue, 27 Aug 2019 17:46:59 GMT
Author: tilman
Date: Tue Aug 27 17:46:58 2019
New Revision: 1865999

URL: http://svn.apache.org/viewvc?rev=1865999&view=rev
Log:
PDFBOX-4638: refactor and treat empty BBox like a missing BBox

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

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java?rev=1865999&r1=1865998&r2=1865999&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Tue Aug 27 17:46:58 2019
@@ -207,8 +207,7 @@ class AppearanceGeneratorHelper
                 // TODO support appearances other than "normal"
                 
                 PDAppearanceStream appearanceStream;
-                if (appearance != null && appearance.isStream() &&
-                        appearance.getAppearanceStream().getBBox() != null)
+                if (isValidAppearanceStream(appearance))
                 {
                     appearanceStream = appearance.getAppearanceStream();
                 }
@@ -239,6 +238,24 @@ class AppearanceGeneratorHelper
         }
     }
 
+    private static boolean isValidAppearanceStream(PDAppearanceEntry appearance)
+    {
+        if (appearance == null)
+        {
+            return false;
+        }
+        if (!appearance.isStream())
+        {
+            return false;
+        }
+        PDRectangle bbox = appearance.getAppearanceStream().getBBox();
+        if (bbox == null)
+        {
+            return false;
+        }
+        return Math.abs(bbox.getWidth()) > 0 && Math.abs(bbox.getHeight()) >
0;
+    }
+
     private PDAppearanceStream prepareNormalAppearanceStream(PDAnnotationWidget widget)
     {
         PDAppearanceStream appearanceStream = new PDAppearanceStream(field.getAcroForm().getDocument());



Mime
View raw message