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 bySetCustomPaperSizeInInches.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.






