Custom PDF Size

This code snippet illustrates how to define custom paper size when rendering HTML content into a PDF document.

Use the paperSize property to customize paper size in the rendering options. Here, the options object is used to specify the custom paper size. It sets the paper size to a custom 5x5-inch dimension. You can adjust the height and width properties as needed to match your desired paper size.

Utilize the PdfDocument.fromHtml method to convert the HTML content into a PDF document, while applying the specified rendering options.

After rendering, the resulting PDF document is saved with the custom paper size using the saveAs method.