We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Wrong page size


i have a pdf document with diferent page sizes. (see attached example)
If I try to get the page width and height for all pages I’ll always get the same size for all documents.

Code attached.


Hi Theo,

Thanks for contacting support.

Please try using following code snippet to get correct page dimensions.


//Open document<o:p></o:p>

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("C:\\pdftest\\HochQuerTest.pdf");

// iterate through pages in PDF document

for(int counter =1; counter <=pdfDocument.getPages().size();counter++)


double pageHeight = pdfDocument.getPages().get_Item(counter).getRect().getHeight();

double pageWidth = pdfDocument.getPages().get_Item(counter).getRect().getWidth();

System.out.println("Page # " + counter + " Height = " + pageHeight / 72 + " Width " + pageWidth / 72);

// in case there is some rotation angle for page, then use following code line

// System.out.println(" 2 + " + pdfDocument.getPages().get_Item(1).getPageRect(true).getWidth() / 72 + "---- h = " + pdfDocument.getPages().get_Item(1).getPageRect(true).getHeight() / 72);



thank you.
Works as expected.


Hi Theo,

Thanks for your acknowledgement.

We are glad to hear that your problem is resolved. Please continue using our API and in the event of any further query, please feel free to contact.