Aspose.PDF.Page Shows incorrect values for PDF Height/Width/Orientation?


We are trying replace our “QuickPDF” component with “Aspose.PDF” and we have an issue with the way Aspose.PDF loads incorrect values for Aspose.Pdf.PageInfo object’s Height/Width/Orientation properties. I am guessing even margins are also loaded incorrectly here.

In order to replicate, just load the pdf file attached here.
CoverPage-1-1414835.pdf (31.5 KB) .

Below is the code snippet we used.

Document pdf = new Document(pdfFilePath);

Refer attached screenshots below which show incorrect values that we get for Height/Width/Orientation/Margin properties in Debug mode both at pdf.PageInfo and pdf.Pages[1].PageInfo level.
Refer the screenshots below.

  1. pdf.PageInfo (177.8 KB)
  2. pdf.Pages[1].PageInfo (178.2 KB)

We believe below are the correct values which you can also verify by just going to pdf document properties window.
Height: 8.5 inch (8.5*72 = 612 points)
Width: 11 inch (11*72 = 792 points)
Orientation: Landscape

Please review and give us a solution as soon as you can.

We are using 22.9.0 version.



PageInfo.Height and PageInfo.Width Properties are used for PDF generation only. They cannot be used to extract values of an existing PDF document. In order to extract these values/dimension, please use doc.Pages[1].GetPageRect(true).Width and doc.Pages[1].GetPageRect(true).Height properties. In case you need further assistance, please feel free to let us know.

Thank you for the quick response.
doc.Pages[1].GetPageRect(true) this works fine for us.

But what about Orientation and Margins? Where can i get the correct values for those?



We will get back to you on it soon.


Since PDF does not have markup information, this information can not be extracted from the existing PDF document by reading document properties or something like this, page content could be analyzed to obtain this information. For page orientation, you can check Page.Rect (and if Page.Rect.Width > Page…Rect.Height this is landscape, and portrait otherwise).

We have also logged an investigation ticket as PDFNET-53347 in our issue tracking system to further analyze this scenario. We will look into details of the ticket and let you know once its resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.