Persits Software, Inc. Knowledge Base Articles

HOWTO: Add A4 pages to PDF documents

Problem Description

When adding pages to a PDF documents with AspPDF, the default page size is US Letter (8.5" x 11"). This articles explains how to change this default behavior.

Solution

A new page is added to the PDF document via the PdfPages.Add method. This method accepts three optional arguments, the first two being Width and Height expressed in user units (1 user unit is 1/72 inch). If omitted, the Width and Height arguments are assumed to be 612 and 792 (8.5" and 11") which corresponds to US Letter page size.

1 inch equals 25.4 mm. To add an A4 page (210mm x 297mm), the following values should be used:

' A4
Set Page = Doc.Pages.Add(595.3, 841.9)

To add a US Legal page (8.5" x 14"), use the values

' US Legal
Set Page = Doc.Pages.Add(612, 1008)