Portrait & Landscape Orientation
IronPDF for Python supports both Landscape and Portrait page orientation for new PDFs, and provides per-page rotation control for existing documents.
Getting Started
For new PDFs, set RenderingOptions.PaperOrientation before calling any render method. For existing PDFs, use SetPageRotation or SetAllPageRotations on a loaded PdfDocument to rotate individual pages or the entire document.
Understanding the Code
New PDFs
PaperOrientation = PdfPaperOrientation.Landscape: Renders the PDF in landscape orientation. UsePortraitto return to the default upright layout.- Works with
RenderHtmlAsPdf,RenderHtmlFileAsPdf, andRenderUrlAsPdf.
Existing PDFs
PdfDocument.FromFile(path): Loads an existing PDF file.Pages[0].PageRotation: Reads the current rotation of the first page (zero-based index).SetPageRotation(PageIndex, Rotation): Rotates a single page to the specified angle.SetAllPageRotations(Rotation): Applies the same rotation to every page in the document.
Rotation Values
The PdfPageRotation enum provides four options:
| Value | Degrees |
|---|---|
None | 0° |
Clockwise90 | 90° |
Clockwise180 | 180° |
Clockwise270 | 270° |






