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

Free Support Forum - aspose.com

Getting page size of the PDF document

I’m interested to get the page size (i.e. A4, A3, Letter etc.) of the PDF pages.

Hi Uva,

You can use getPageWidth and getPageHeight methods of PdfFileInfo class to get the page height and width. You can also change the height and width of the pages using changePageSize method of PdfFileEditor class. Please see the code snippet below to see how you can get or set the page size. Moreover, the unit of measurement is point.


//get page size: height and width

PdfFileInfo info = new PdfFileInfo(“input.pdf”);

System.out.println("Before: " + info.getPageWidth(1) + " " + info.getPageHeight(1));


//set page size

PdfFileEditor editor = new PdfFileEditor();

editor.changePageSize(“input.pdf”, “output.pdf”, PageSize.LETTER);


//get page size: height and width

info = new PdfFileInfo(“output.pdf”);

System.out.println("After: " + info.getPageWidth(1) + " " + info.getPageHeight(1));




I hope this helps. If you have any further questions, please do let us know.
Regards,