Author: tilman
Date: Sun Aug 10 07:17:20 2025
New Revision: 1927724

Log:
PDFBOX-6049: refactor

Modified:
   pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java   
Sun Aug 10 03:20:15 2025        (r1927723)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java   
Sun Aug 10 07:17:20 2025        (r1927724)
@@ -506,16 +506,7 @@ public class Overlay implements Closeabl
                 PDPage page = inputPDFDocument.getPage(pageNumber - 1);
                 if (page.getRotation() != 0)
                 {
-                    LayoutPage rotatedLayoutPage = 
rotatedDefaultOverlayPagesMap.get(page.getRotation());
-                    if (rotatedLayoutPage == null)
-                    {
-                        // createLayoutPage must be called because we can't 
reuse the COSStream
-                        rotatedLayoutPage = 
createLayoutPage(defaultOverlayDocument.getPage(0));
-                        int newRotation = (rotatedLayoutPage.overlayRotation - 
page.getRotation() + 360) % 360;
-                        rotatedLayoutPage.overlayRotation = newRotation;
-                        rotatedDefaultOverlayPagesMap.put(page.getRotation(), 
rotatedLayoutPage);
-                    }
-                    return rotatedLayoutPage;
+                    return createAdjustedLayoutPage(page);
                 }
             }
         }
@@ -527,6 +518,20 @@ public class Overlay implements Closeabl
         return layoutPage;
     }
 
+    private LayoutPage createAdjustedLayoutPage(PDPage page) throws IOException
+    {
+        LayoutPage rotatedLayoutPage = 
rotatedDefaultOverlayPagesMap.get(page.getRotation());
+        if (rotatedLayoutPage == null)
+        {
+            // createLayoutPage must be called because we can't reuse the 
COSStream
+            rotatedLayoutPage = 
createLayoutPage(defaultOverlayDocument.getPage(0));
+            int newRotation = (rotatedLayoutPage.overlayRotation - 
page.getRotation() + 360) % 360;
+            rotatedLayoutPage.overlayRotation = newRotation;
+            rotatedDefaultOverlayPagesMap.put(page.getRotation(), 
rotatedLayoutPage);
+        }
+        return rotatedLayoutPage;
+    }
+
     private PDFormXObject createOverlayFormXObject(LayoutPage layoutPage, 
PDFCloneUtility cloner)
             throws IOException
     {
@@ -836,6 +841,5 @@ public class Overlay implements Closeabl
     public void setAdjustRotation(boolean adjustRotation)
     {
         this.adjustRotation = adjustRotation;
-
     }
 }

Reply via email to