Author: tilman
Date: Mon Aug 18 03:40:24 2025
New Revision: 1927846
Log:
PDFBOX-5660: simplify code, as suggested by Valery Bokov; closes #216
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
==============================================================================
---
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
Mon Aug 18 02:49:34 2025 (r1927845)
+++
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
Mon Aug 18 03:40:24 2025 (r1927846)
@@ -500,9 +500,10 @@ public class Overlay implements Closeabl
// Note that this segment is only the second best solution to
the problem. The best
// would be to make appropriate transforms in
calculateAffineTransform()
PDPage page = inputPDFDocument.getPage(pageNumber - 1);
- if (page.getRotation() != 0)
+ int rotation = page.getRotation();
+ if (rotation != 0)
{
- return createAdjustedLayoutPage(page);
+ return createAdjustedLayoutPage(rotation);
}
}
}
@@ -514,16 +515,16 @@ public class Overlay implements Closeabl
return layoutPage;
}
- private LayoutPage createAdjustedLayoutPage(PDPage page) throws IOException
+ private LayoutPage createAdjustedLayoutPage(int rotation) throws
IOException
{
- LayoutPage rotatedLayoutPage =
rotatedDefaultOverlayPagesMap.get(page.getRotation());
+ LayoutPage rotatedLayoutPage =
rotatedDefaultOverlayPagesMap.get(rotation);
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;
+ int newRotation = (rotatedLayoutPage.overlayRotation - rotation +
360) % 360;
rotatedLayoutPage.overlayRotation = newRotation;
- rotatedDefaultOverlayPagesMap.put(page.getRotation(),
rotatedLayoutPage);
+ rotatedDefaultOverlayPagesMap.put(rotation, rotatedLayoutPage);
}
return rotatedLayoutPage;
}