IRONSOFTWAREHOME
Portrait & Landscape Orientation
from ironpdf import *
 
# For NEW PDF Documents use PdfPaperOrientation
# PdfPaperOrientation: To choose Landscape or Portrait Orientation in a new PDF document
renderer = ChromePdfRenderer()
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape

new_pdf_from_html = renderer.RenderHtmlAsPdf("<h1> Hello World! </h1>")
new_pdf_from_html_file = renderer.RenderHtmlFileAsPdf("example.html")
new_pdf_from_url = renderer.RenderUrlAsPdf("https://ironpdf.com")

# For EXISTING PDFs use PageRotation
# PageRotation: To rotate a PDF page and all of its contents
existing_pdf = PdfDocument.FromFile("old_report.pdf")

# Get rotation value
get_rotation_first_page = existing_pdf.Pages[0].PageRotation

# Rotate specified page
existing_pdf.SetPageRotation(PageIndex=0, Rotation=PdfPageRotation.Clockwise90)

# Rotate ALL pages
existing_pdf.SetAllPageRotations(PdfPageRotation.Clockwise270)
pip install ironpdf
Portrait & Landscape Orientation

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
None0°
Clockwise9090°
Clockwise180180°
Clockwise270270°
Learn to customize PDF layout with IronPDF for Python!

Ready to Get Started?

Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Python Module Download for PDF
Install with pip

Version: 2026.9

  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module

Version: 2026.9

Manually install into your project

  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2026.9-py37-none-win_amd64.whi

Licenses from $999