Portrait & Landscape Orientation
When creating or rendering your PDF in IronPDF, you can choose from one of two orientations of how you want your document to be. The PdfPaperOrientation
class determines the paper orientation when rendering HTML to PDF.
This example shows you how to set a paper orientation for your documents.
IronPDF has two different values in PDFs called PaperOrientation
and PageRotation
. Both are used differently. Not only that, you need to know when to use which.
PdfPaperOrientation
- This is for NEW PDF Documents rendered from HTML or URL:
- This is only valid as a setting when rendering a document from HTML or from a URL.
- For Landscape use:
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;
- For Portrait use:
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Portrait;
- However, the information is then LOST after the document is rendered.
PageRotation - This is used for already existing PDF Documents:
- This is only valid as a property of an existing document. (Meaning this cannot be specified during rendering of a new document).
- This information is stored as part of the document itself. On a per-page basis.
- Pages of newly rendered documents will always have a default
PageRotation
ofNone
. - The value of
PageRotation
does NOT have any affect on thewidth
andheight
of the page. - Specifying a
PageRotation
ofNone
on a210mm x 297mm
page will result in a page withwidth=210 height=297
- Specifying a
PageRotation
ofClockwise90
on a210mm x 297mm
page will result in a page withwidth=210 height=297