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

Free Support Forum - aspose.com

PageInfo.IsLandscape returning inaccurate Information


Currently i try to figure out if every page of a PDF-Document is in Portrait/Landscape format.
I have found the Property “IsLandscape” at Aspose.PDF.Document.Pages.Page.PageInfo.IsLandscape.

How to use this functionality?
I have a MS-Word Documet with a few A4-Pages, some in Portrait, some in Landscape format. Im saving this Document as a PDF and load it by using the Aspose.PDF.Document class.
If i iterate through every page and query the “IsLandscape” property… for every page it returns “FALSE” - Which is incorrect! - How do you determine this? By Rotation or checking the Page-Rectangle for its size?

Im using Aspose.Pdf .net ""

Thanks in advance

Hi Johannes,

Thanks for your inquriy. Please note PageInfo.IsLandscape property is used while creating a PDF document from scratch. Please try following code snippet to get page orientation, it also consider page rotation. Hopefully it will help you to accomplish the task. However if the issue persist then please share your sample PDF document here, so we will look into it and will guide you accordingly.

Aspose.Pdf.Document doc = new Aspose.Pdf.Document(“Input.pdf”);<o:p></o:p>

foreach (Aspose.Pdf.Page page in doc.Pages)<o:p></o:p>


Aspose.Pdf.Rectangle rect = page.GetPageRect(true);<o:p></o:p>

Console.WriteLine(“Page {0} width is {1} and heigth is {2}, rotation: {3}, size considering rotation: widht {4} : height {5}”, page.Number, page.Rect.Width, page.Rect.Height, page.Rotate.ToString(), rect.Width, rect.Height);<o:p></o:p>

if (rect.Width > rect.Height)<o:p></o:p>

Console.WriteLine(“Page no{0}: Landscape”,page.Number);<o:p></o:p>


Console.WriteLine(“Page no{0}: Portrait”, page.Number);<o:p></o:p>


<o:p> </o:p>

<o:p>Please feel free to contact us for any further assistance.</o:p>


<o:p>Best Regards,</o:p>


Thank you for your response!

Best Regards