IRONSOFTWAREHOME
Custom PDF Size
from ironpdf import *
 
html = "<p>Lorem ipsum dolor sit amet..."

renderer = ChromePdfRenderer()
renderer.RenderingOptions.PaperSize = PdfPaperSize.Custom
renderer.RenderingOptions.SetCustomPaperSizeInInches(5.0, 5.0)

pdf = renderer.RenderHtmlAsPdf(html)

pdf.SaveAs("CustomPaperSize.pdf")
pip install ironpdf
Custom PDF Size

Custom PDF Size

IronPDF for Python allows you to render PDFs at any custom paper size, overriding the standard A4 or Letter dimensions with an exact width and height specified in inches.

Getting Started

Set RenderingOptions.PaperSize = PdfPaperSize.Custom and then call SetCustomPaperSizeInInches(width, height) with your desired dimensions before rendering.

Understanding the Code

  • PaperSize = PdfPaperSize.Custom: Switches the renderer away from standard paper size presets and enables the custom size defined by SetCustomPaperSizeInInches.
  • SetCustomPaperSizeInInches(width, height): Sets the exact page dimensions in inches. In this example, both width and height are set to 5.0 inches, producing a square page.
  • RenderHtmlAsPdf(html): Renders the HTML content at the custom paper size.
  • SaveAs("CustomPaperSize.pdf"): Saves the output file.

Standard Paper Size Presets

If a custom size is not required, IronPDF also supports standard presets via the PdfPaperSize enum, including:

A0-A9, B0-B9, Letter, Legal, Tabloid, and many others.

Assign the desired preset to RenderingOptions.PaperSize without calling SetCustomPaperSizeInInches.

Learn to customize PDF output 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