Hi,

Thanks for reporting, I created https://issues.apache.org/jira/browse/PDFBOX-5919 . Likely a mistake in refactoring, the javadoc is clear that it should return the cropbox if trimbox doesn't exist.

Sadly I can't fix it right now because of network problems (either from my ISP or from Apache or in between)

Tilman

On 06.12.2024 09:01, Bart Klein Ikink wrote:
I have a test where I do:

try (PDDocument document = Loader.loadPDF(new 
ClassPathResource("/A5.pdf").getFile())) {
     PDPage page = document.getPage(0);

     assertTrue(isStandardPageSize(page.getMediaBox(), A5));
     assertTrue(isStandardPageSize(page.getCropBox(), A5));
     assertTrue(isStandardPageSize(page.getTrimBox(), A5));

After migrating, it fails on page.getTrimBox()

java.lang.NullPointerException: Cannot invoke 
"org.apache.pdfbox.pdmodel.common.PDRectangle.getWidth()" because "box" is null

Under pdfbox 2.0.26 the code worked fine. It was:

         try (PDDocument document = PDDocument.load(new 
ClassPathResource("/A5.pdf").getInputStream())) {

     PDPage page = document.getPage(0);

     assertTrue(isStandardPageSize(page.getMediaBox(), A5));
     assertTrue(isStandardPageSize(page.getCropBox(), A5));
     assertTrue(isStandardPageSize(page.getTrimBox(), A5));

So, MediaBox and Cropbox still work but not Trimbox.




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to