Author: tilman
Date: Mon Aug 18 03:40:28 2025
New Revision: 1927847
Log:
PDFBOX-5660: simplify code, as suggested by Valery Bokov; closes #216
Modified:
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
Modified:
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
==============================================================================
---
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
Mon Aug 18 03:40:24 2025 (r1927846)
+++
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
Mon Aug 18 03:40:28 2025 (r1927847)
@@ -505,9 +505,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);
}
}
}
@@ -519,16 +520,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;
}