IRONSOFTWAREHOME

How to Render PDFs with Custom Paper Size in C#

Curtis Chau
Curtis Chau
Updated: September 5, 2026

IronPDF enables you to render PDFs with custom paper sizes in C# by using the ChromePdfRenderer class and setting specific dimensions through methods like SetCustomPaperSizeInInches(), allowing precise control over document dimensions for specialty layouts like posters or banners.

A custom paper size refers to a non-standard paper size that is defined by the user rather than being a standard size like A4 or letter size (8.5 x 11 inches). Custom paper sizes are often used when printing documents that require a unique or specific layout, such as posters, banners, or specialty documents. This flexibility is essential when working with HTML to PDF conversion projects that require specific dimensions.

Discover the extensive range of paper sizes available with IronPDF, offering a wide selection to suit your needs!

Quickstart: Define Custom Paper Sizes in IronPDF

In this quick guide, learn how to set custom paper sizes using IronPDF in just a few lines of code. With IronPDF, you can easily tailor PDF dimensions by defining exact width and height measurements in any unit you prefer. This flexibility is ideal for creating documents with unique layout requirements, such as posters or banners. Begin by downloading the IronPDF library via NuGet and follow this example to set your desired paper size effortlessly.

  1. 1Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. 2Copy and run this code snippet.

    var renderer = new IronPdf.ChromePdfRenderer { RenderingOptions = { PaperSize = IronPdf.Rendering.PdfPaperSize.Custom } };
    renderer.RenderingOptions.SetCustomPaperSizeInInches(5, 7);
    renderer.RenderHtmlAsPdf("<h1>Custom size</h1>").SaveAs("custom-size.pdf")
    C#
  3. 3Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer

How Do I Use Standard Paper Sizes?

First, create an instance of the ChromePdfRenderer class. Then, use the RenderingOptions property of the newly created object to modify the PaperSize. Set it to one of the predefined values from the PdfPaperSize enum to specify the desired paper size. We offer over 100 predefined standard paper sizes for your convenience.

When working with PDF rendering options, IronPDF provides comprehensive control over how your documents are formatted. The standard paper sizes include commonly used formats like A4, Letter, Legal, and many international standards.

Which Standard Paper Sizes Are Available?

Below is an example of how to set a standard paper size:

using IronPdf;
using IronPdf.Rendering;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// Set paper size to A4
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;

PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Standard Paper Size</h1>");

pdf.SaveAs("standardPaperSize.pdf");

IronPDF supports an extensive collection of standard paper sizes including:

  • ISO 216 Series: A0 through A10, B0 through B10
  • North American: Letter, Legal, Tabloid, Executive
  • Architectural: ANSI A through E
  • Japanese: JIS B0 through B10
  • Envelope Sizes: Various international envelope standards

For a complete list of available paper sizes and their dimensions, refer to the API Reference documentation.

What Properties Control Paper Size?

  • PaperSize: Set an output paper size for PDF pages with predefined sizes such as letter, A3, A4, etc.
  • ForcePaperSize: Forces page sizes to be exactly what is specified via IronPdf.ChromePdfRenderOptions.PaperSize by resizing the page after generating a PDF from HTML. This feature is useful for bypassing CSS rules that specify paper size.

When using these properties in conjunction with custom margins, you can achieve precise control over your PDF layout.

How Do I Get Standard Paper Sizes in Different Units?

Need to find the dimensions of standard paper sizes? You can easily do so using the ToMillimeters method. This method returns a tuple containing the width and height of the standard paper size as Length objects. The Length class is incredibly versatile, allowing you to effortlessly convert these dimensions into a variety of units, including:

  • Millimeters
  • Centimeters
  • Inches
  • Pixels
  • Points
using IronPdf.Rendering;

double A4WidthInPixel = PdfPaperSize.A4.ToMillimeters().width.ToPixel();
double A4HeightInCentimeter = PdfPaperSize.A4.ToMillimeters().height.ToCentimeter();

This functionality is particularly useful when integrating with CSS responsive layouts or when you need to calculate exact dimensions for custom layouts.


My favorite library of this kind is IronPDF. It allows for fast and efficient manipulation of PDF files. It also has many valuable features, like exporting to PDF/A format and digitally signing PDF documents.

Milan Jovanovic

Microsoft MVP

View case study

IronOCR means we can save $40,000 annually from manual processing, while enhancing productivity and freeing up resources for high-impact tasks. I would highly recommend it.

Brent Matzelle

Chief Technology Officer, OPYN

View case study

The IronSuite play a crucial role in our operations. These are tools that increase efficiencies across the business including creating floor plans and improving inventory management.

David Jones

Lead Software Engineer, Agorus Build

View case study

How Do I Create Custom Paper Sizes?

First, we begin by instantiating the ChromePdfRenderer class. From the newly created object, we can access the RenderingOptions to apply a custom paper size to the newly generated PDF document. There are four methods that can be used to set the output paper size for PDF pages, each based on a different measurement unit:

  • SetCustomPaperSizeInCentimeters: Dimensions are in centimeters.
  • SetCustomPaperSizeInInches: Dimensions are in inches.
  • SetCustomPaperSizeInMillimeters: Dimensions are in millimeters.
  • SetCustomPaperSizeInPixelsOrPoints: Dimensions are in pixels or points.

When creating custom paper sizes, it's important to consider how they will interact with headers and footers as well as page orientation settings.

What Units Can I Use for Custom Dimensions?

Below is an example of how to set a custom paper size in centimeters:

using IronPdf;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// Set custom paper size in cm
renderer.RenderingOptions.SetCustomPaperSizeinCentimeters(15, 15);

PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Custom Paper Size</h1>");

pdf.SaveAs("customPaperSize.pdf");

Here are additional examples for each measurement unit:

// Example: Custom paper size in inches (for US letter-like custom size)
renderer.RenderingOptions.SetCustomPaperSizeInInches(8.5, 11.5);

// Example: Custom paper size in millimeters (for precise metric measurements)
renderer.RenderingOptions.SetCustomPaperSizeInMillimeters(297, 420); // A3 size

// Example: Custom paper size in pixels (useful for screen-based layouts)
renderer.RenderingOptions.SetCustomPaperSizeInPixelsOrPoints(1024, 768, 96); // 96 DPI

When working with custom sizes, you might also want to explore viewport and zoom settings to ensure your content fits properly within the custom dimensions.


How Can I Modify Paper Dimensions?

In an existing PDF document or a freshly rendered PDF, the size of each page can be modified using the ExtendPage method. This method allows you to specify the target page index, the values to modify each of the four sides, and the units of measurement. The values for each side can be negative, which will reduce that particular side, or positive, which will extend that side.

This feature is particularly useful when you need to adjust PDFs after they've been created, such as when merging multiple PDFs with different page sizes or when preparing documents for printing.

What Parameters Does ExtendPage Accept?

The ExtendPage method accepts the following parameters:

  • Page Index: The zero-based index of the page to modify
  • Left Extension: Amount to extend/reduce the left side
  • Right Extension: Amount to extend/reduce the right side
  • Top Extension: Amount to extend/reduce the top side
  • Bottom Extension: Amount to extend/reduce the bottom side
  • Measurement Unit: The unit of measurement (millimeters, inches, etc.)

Below is an example of how to modify paper dimensions:

using IronPdf;
using IronPdf.Editing;

PdfDocument pdf = PdfDocument.FromFile("customPaperSize.pdf");

pdf.ExtendPage(0, 50, 0, 0, 0, MeasurementUnit.Millimeter);

pdf.SaveAs( "extendedLeftSide.pdf");

Here's a more comprehensive example showing various page modifications:

// Extend all sides equally
pdf.ExtendPage(0, 10, 10, 10, 10, MeasurementUnit.Millimeter);

// Reduce page size (negative values)
pdf.ExtendPage(1, -20, -20, -10, -10, MeasurementUnit.Millimeter);

// Extend only top and bottom (useful for adding header/footer space)
pdf.ExtendPage(2, 0, 0, 25, 25, MeasurementUnit.Millimeter);

// Work with inches instead of millimeters
pdf.ExtendPage(3, 0.5, 0.5, 1, 1, MeasurementUnit.Inch);

Best Practices for Custom Paper Sizes

When working with custom paper sizes in IronPDF, consider these best practices:

  1. Test Different Units: While working with custom sizes, test which measurement unit works best for your use case. Pixels are great for screen-based layouts, while millimeters or inches are better for print.
  2. Consider Print Margins: When creating PDFs for printing, remember to account for printer margins. Most printers cannot print to the edge of the paper.
  3. Responsive Design: When converting HTML to PDF, ensure your HTML uses responsive design principles to adapt to different paper sizes.
  4. Performance Optimization: Very large custom paper sizes can impact performance. Consider using compression for large documents.
  5. Compatibility: Test your custom-sized PDFs in different PDF viewers to ensure compatibility, especially if using non-standard dimensions.

Ready to see what else you can do? Check out our tutorial page here: Create PDFs

Frequently Asked Questions

How do I create a PDF with a custom paper size using IronPDF in C#?

You can create a PDF with a custom paper size using IronPDF's `ChromePdfRenderer` class. By utilizing the `SetCustomPaperSizeInInches()` method, you can set exact dimensions in inches to achieve the desired paper size, suitable for unique layouts like posters or banners.

What units of measurement can I use for custom paper sizes in IronPDF?

IronPDF allows you to set custom paper sizes in different units including inches, centimeters, millimeters, and pixels. Use methods like `SetCustomPaperSizeInInches()`, `SetCustomPaperSizeInCentimeters()`, and others to define your paper size according to your preferred unit.

Can I modify paper dimensions in an existing PDF with IronPDF?

Yes, you can modify paper dimensions in an existing PDF using IronPDF's `ExtendPage` method. This method lets you adjust each side of a page by specifying the amount to extend or reduce and the measurement unit.

How do I integrate HTML to PDF conversion with custom paper sizes in IronPDF?

To integrate HTML to PDF conversion with custom paper sizes in IronPDF, define your desired paper layout using methods like `SetCustomPaperSizeInInches()`, and then use the `RenderHtmlAsPdf()` method to convert HTML content to PDF with the specified dimensions.

Does IronPDF support standard paper sizes, and how can I set one?

Yes, IronPDF supports over 100 standard paper sizes. You can set a standard paper size by accessing the `RenderingOptions.PaperSize` property of the `ChromePdfRenderer` class and assigning it a predefined value from the `PdfPaperSize` enum, such as A4 or Letter.

What is the purpose of the `ForcePaperSize` option in IronPDF?

The `ForcePaperSize` option in IronPDF ensures that the page size is exactly as specified by resizing the page after generating a PDF from HTML. This overrides any CSS rules that might specify a different paper size, providing consistency in your PDF dimensions.

How can I ensure my custom paper sizes are compatible with different PDF viewers?

For compatibility with different PDF viewers, test your custom-sized PDFs in multiple viewers and ensure your dimensions adhere to PDF standards. Additionally, consider factors like printer margins for print-ready documents.

What should I consider when setting custom paper sizes for print in IronPDF?

When setting custom paper sizes for print, consider the printer margins since most printers cannot print to the edge. Use appropriate units like millimeters or inches, and verify the dimensions using the `ExtendPage` method if adjustments are needed post-creation.

How do I convert standard paper sizes to different units in IronPDF?

You can convert standard paper sizes to different units using IronPDF’s `ToMillimeters` method. This method provides the width and height as `Length` objects, which can easily be converted into millimeters, centimeters, inches, pixels, or points.

What are some best practices for using custom paper sizes in IronPDF?

Some best practices include testing different units for suitability, considering print margins, ensuring your HTML uses responsive design for HTML to PDF conversion, optimizing performance for very large sizes, and testing compatibility across different PDF viewers.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 21,105,021Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999

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
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999