IRONSOFTWAREHOME
Custom PDF Size

import com.ironsoftware.ironpdf.*;  
import com.ironsoftware.ironpdf.render.*;  
import java.io.IOException;  
import java.nio.file.Paths;

String html = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>";  
  
ChromePdfRenderOptions renderOptions = new ChromePdfRenderOptions();  
renderOptions.setPaperSize(PaperSize.Custom);  
  
/*  
 * Setting page sizes using different measuring units: * 1. setCustomPaperWidth( width ) / setCustomPaperHeight( height ): for inches * 2. setCustomPaperSizeInCentimeters( width, height ): for centimeters. * 3. setCustomPaperSizeInMillimeters( width, height ): for millimeters * 4. setCustomPaperSizeInPixelsOrPoints( width, height ): for pixels/points */renderOptions.setCustomPaperSizeInCentimeters(13.97, 13.97);  
  
PdfDocument.renderHtmlAsPdf(html, renderOptions).saveAs(Paths.get("assets/CustomPaperSize.pdf"));
mvn install
Custom PDF Size

Custom PDF Size

With IronPDF, developers can generate PDF documents with dimensions sized other than the standard A4 (8½ by 11 inches, or 21.59 by 27.94 centimeters).

Render PDFs with different paper sizes by specifying the desired dimensions in a ChromePdfRenderOptions object with the setPaperSize method. Set the paper size in the method argument with a preset PaperSize value. Afterward, render the PDF document as usual from the source content (HTML string, URL, HTML file, etc.).

The PaperSize enum type supports over 100 industry-recognized print sizes. This provides coverage for those sizes used in the majority of business cases. To use a different print size other than the ones included in the PaperSize enum, choose PaperSize.Custom and set the desired page width and page height manually:

As shown above, setCustomPaperWidth and setCustomPaperHeight accept number values representing the desired dimensions in inches. To set the dimensions using centimeters, use setCustomPaperSizeInCentimeters. To set the dimensions in millimeters, use setCustomPaperSizeInMillimeters. For pixels/points, use setCustomPaperSizeInPixelsOrPoints.

Learn more about setting custom PDF sizes with IronPDF.
View on GitHub

Ready to Get Started?

Version:2026.8just 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
Java Maven Library for PDF
Install with Maven

Version: 2026.8

<dependency>
   <groupId>com.ironsoftware</groupId>
   <artifactId>ironpdf</artifactId>
   <version>2026.8.2</version>
</dependency>
https://central.sonatype.com/artifact/com.ironsoftware/ironpdf/2026.8.2
or
Java PDF JAR
Download JAR

Version: 2026.8

Manually install into your project