Author: tilman
Date: Mon Jul 27 10:08:07 2026
New Revision: 1936626

Log:
PDFBOX-6223: check whether new BBox differs from existing one

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

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
  Mon Jul 27 10:08:04 2026        (r1936625)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
  Mon Jul 27 10:08:07 2026        (r1936626)
@@ -243,7 +243,7 @@ class AppearanceGeneratorHelper
             PDAppearanceStream appearanceStream;
             // We're using the existing appearance if possible (since 2013 or 
even earlier)
             // However, except for the file from PDFBOX-2586 we could ignore it
-            if (isValidAppearanceStream(appearance, widgetRotation, newBBox))
+            if (isValidAppearanceStream(appearance, newBBox))
             {
                 appearanceStream = appearance.getAppearanceStream();
             }
@@ -252,7 +252,7 @@ class AppearanceGeneratorHelper
                 appearanceStream = prepareNormalAppearanceStream(widget, 
newBBox, widgetRotation);
                 appearanceDict.setNormalAppearance(appearanceStream);
             }
-                
+
             /*
              * Adobe Acrobat always recreates the complete appearance stream 
if there is an appearance characteristics
              * entry (the widget dictionaries MK entry). In addition if there 
is no content yet also create the appearance
@@ -265,8 +265,7 @@ class AppearanceGeneratorHelper
             }
                 
             setAppearanceContent(widget, appearanceStream);
-            
-            
+
             // restore the field level appearance
             defaultAppearance =  acroFormAppearance;
         }
@@ -295,7 +294,7 @@ class AppearanceGeneratorHelper
         return apValue;
     }
 
-    private static boolean isValidAppearanceStream(PDAppearanceEntry 
appearance, int widgetRotation, PDRectangle newBBox)
+    private static boolean isValidAppearanceStream(PDAppearanceEntry 
appearance, PDRectangle newBBox)
     {
         if (appearance == null)
         {
@@ -310,6 +309,11 @@ class AppearanceGeneratorHelper
         {
             return false;
         }
+        if (Math.abs(newBBox.getWidth() - bbox.getWidth()) > 1 || 
Math.abs(newBBox.getHeight() - bbox.getHeight()) > 1)
+        {
+            // PDFBOX-6223: don't like it if bbox and rectangle are of very 
different sizes
+            return false;
+        }
         return Math.abs(bbox.getWidth()) > 0 && Math.abs(bbox.getHeight()) > 0;
     }
 

Reply via email to