Set Custom Margins

IronPDF creates new PDF documents with 25-millimeter margins (top, bottom, left, and right) by default. However, IronPDF allows developers to set custom measurements for each margin as needed to achieve specific design criteria.

Developers can define custom margins for new PDFs using ChromePdfRenderOptions. The featured code example sets custom values for all four margins: 20-millimeter left and right margins and 40-millimeter top and bottom margins.

Specify PDF margins suitable for any document type: letters, posters, postcards, etc--or, create borderless documents suitable for commercial printing by setting each margin to zero millimeters. Use ChromePdfRenderOptions objects with PDF rendering methods (renderUrlAsPdf, renderHtmlAsPdf, and renderHtmlFileAsPdf) to define additional print-specific options apart from margin sizes, such as paper size, DPI, headers and footers, and others. View more information about available customization options on the ChromePdfRenderOptions API Reference page.