I would think the latter would be the best approach. A scenario is: Someone scans a document into a PDF. Some of the scanned pages are fed upside down. In order to correct this, we simply go into Adobe and rotate those pages. Therefore, to get the overlay to match the rotation of the page, I would think the overlay would be rotated. However, we'll look at the code you have provided and see if that gains us some ground. If we get it working I'll let you know.
Thank you for your help, Brent ---------- Forwarded message --------- From: Tilman Hausherr <thaush...@t-online.de> Date: Thu, Aug 7, 2025 at 8:23 AM Subject: Re: Overlay not rendering To: <users@pdfbox.apache.org> What should really be done is to add something like this near the end of calculateAffineTransform(): switch (page.getRotation()) { case 90: at.rotate(Math.toRadians(90), hShift, vShift); break; case 180: at.rotate(Math.toRadians(180), hShift, vShift); break; case 270: // at.translate(0, pageMediaBox.getWidth() - overlayMediaBox.getWidth()); // at.rotate(Math.toRadians(270)); at.rotate(Math.toRadians(270), hShift, vShift); break; default: break; } However it doesn't appear at the proper place. The commented code shows it a bit better but still not correct. An alternative would be that I change the Overlay code so that automatically adds a rotation entry to the overlay and thus creates 4 different ones depending on the rotation of the source document page. Tilman