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. Use Portrait to return to the default upright layout.
  • Works with RenderHtmlAsPdf, RenderHtmlFileAsPdf, and RenderUrlAsPdf.

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:

ValueDegrees
None
Clockwise9090°
Clockwise180180°
Clockwise270270°

Learn to customize PDF layout with IronPDF for Python!

Ready to Get Started?
Version: 2026.6 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast?
run a sample watch your HTML become a PDF.