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

Free Support Forum - aspose.com

Failed to read width and height of the PDF document

We are trying to read pdf document width and height using aspose but it is giving wrong details.Please find my observations below.

Note :
If i try to read the same document with itextsharp it is giving exact dimensions.

I will attach the PDF file for reference.
Ex: 1. Using Itext Sharp – 644.4x203.
2. Using Aspose.PDF – 595x842.

Here comes sample program
//WIth Itext Sharp

PdfReader pdfReader = new PdfReader(sourcePdfUrl);
iTextSharp.text.Rectangle currentPageRectangle = pdfReader.GetPageSize(1);
Width =currentPageRectangle.Width;
Height =currentPageRectangle.Height;

//With Aspose
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(sourcePdfUrl);
Width =pdfDocument.PageInfo.Width;
Height = pdfDocument.PageInfo.Height;

Thanks in advance!YOUR_LOGO.pdf (283.3 KB)


Thank you for contacting support.

We would like to update you that PageInfo class contains default values which can be changed while creating new pages. Whereas, you may retrieve meta information with PdfFileInfo class. Please try using below code snippet to read actual width and height of pages.

Document document = new Document(dataDir + "YOUR_LOGO.pdf");
PdfFileInfo info = new PdfFileInfo(document);
Console.WriteLine("Width: " + info.GetPageWidth(document.Pages[1].Number));
Console.WriteLine("Height: " + info.GetPageHeight(document.Pages[1].Number));
Console.WriteLine("Height: " + info.GetPageHeight(1));

We hope this will be helpful. Please feel free to contact us if you need any further assistance.