Problem with Page-Sizes of PDF

Hallo,
we use Java PDF lib V 25.5. I tried also V 25.7, but the same problem occurs:
I have to get the exact page-sizes for every PDF-Page. If I call

page = pdf.getPages().get_Item(j);
pageInfo = page.getPageInfo();

I always get width and height of the first page, and not of the current page.

Please find attached a sample pdf to reproduce this problem:
hoch-und-quer.tess.pdf (2.2 MB)

@GRein

Hallo! Es klingt so, als ob du Schwierigkeiten hast, die genauen Seitenmaße für jede Seite in deinem PDF-Dokument zu erhalten. Wenn du beim Abrufen der Seiteninformationen immer nur die Maße der ersten Seite erhältst, könnte das an der Art liegen, wie du die Seiten abfragst.

Hier ist ein Beispiel, wie du die Seitenmaße für jede Seite korrekt abrufen kannst:

Document pdfDocument = new Document("dein_dokument.pdf");
for (int j = 1; j <= pdfDocument.getPages().size(); j++) {
    Page page = pdfDocument.getPages().get_Item(j);
    PageInfo pageInfo = page.getPageInfo();
    System.out.println("Seite " + j + ": Breite = " + pageInfo.getWidth() + ", Höhe = " + pageInfo.getHeight());
}

Stelle sicher, dass du die Schleife von 1 bis zur Anzahl der Seiten im Dokument durchläufst, da die Seitenindizes in Aspose.PDF bei 1 beginnen. Wenn du weiterhin Probleme hast, überprüfe das PDF-Dokument, um sicherzustellen, dass jede Seite tatsächlich unterschiedliche Maße hat.

Falls du weitere Fragen hast oder zusätzliche Unterstützung benötigst, lass es mich wissen! Ich helfe dir gerne weiter.

Hallo,
this is exactly what I did and I received the wrong values. Please look at the attached pdf.
Kind regards, Gerd

@GRein

Please check below code snippet that should be used to get height and width of the PDF pages:

Page page = doc.getPages().get_Item(1);
double originalWidth = page.getPageRect(true).getWidth();
double originalHeight = page.getPageRect(true).getHeight();
System.out.println(originalWidth);
System.out.println(originalHeight);

Please note that PageInfo is only there to be used during the generation of PDF document. To extract the page size in existing PDF, above approach should be used. In case you still notice any issues, please let us know.

Hallo,
thank you, this is really helpful and it works as described.
This information should be integrated in the API-Documentation.

Kind regards, Gerd

@GRein

Thanks for the feedback. We will surely update the API Documentation accordingly.