Author: tilman
Date: Mon Jul 27 10:08:01 2026
New Revision: 1936624

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

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
==============================================================================
--- 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
  Mon Jul 27 09:51:55 2026        (r1936623)
+++ 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
  Mon Jul 27 10:08:01 2026        (r1936624)
@@ -234,7 +234,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();
             }
@@ -287,7 +287,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) {
             return false;
@@ -299,6 +299,11 @@ class AppearanceGeneratorHelper {
         if (bbox == null) {
             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