How to get the page size and orientation of the loaded document in a PDFLoadedDocument ?
You can get the page size from the existing document by using the property called Size available in the class PDFLoadedPage. Currently, Syncfusion® does not have the property to get the PDF orientation, but you can work around this by comparing the actual page width and height.
Refer to the following code to get the page size and its orientation.
C#
//Loading the PDF document. PdfLoadedDocument lDoc = new PdfLoadedDocument("../../Invoice.pdf"); //Getting the page size. SizeF size = lDoc.Pages[0].Size; MessageBox.Show("Page Width is " + size.Width.ToString() + " " + "Page Height is " + size.Height.ToString()); //Getting the Document Orientation. PdfPageOrientation orientation; if(size.Width>size.Height) { orientation= PdfPageOrientation.Landscape; MessageBox.Show("Document Orientation is Landscape"); } else if(size.Width<size.Height) { orientation = PdfPageOrientation.Portrait; MessageBox.Show("Document Orientation is Potrait"); }
Sample Link:
Conclusion
I hope you enjoyed learning about how to get the page size and orientation of the loaded document in a PDFLoadedDocument.
You can refer to our WinForms PDF feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms PDF example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!