Adding Pages

After creating a Document, the fundamental building block for creating a PDF document is the Page class. To create a document, you add one or more pages to the Document class's Pages collection.

The Page class has eight overloaded constructors allowing you to set the page's dimensions, orientation, size, and width and height. Refer to the API for a complete list of constructors (Page Constructors).

If you need to convert an entire HTML page to a PDF page, refer to the HtmlLayout documentation topic.

Example

The following example illustrates adding pages of several different dimensions to a PDF document using several different constructor overloads.

Document document = new();
document.Pages.Add(new Page(PageSize.Legal));
document.Pages.Add(new Page(PageSize.Letter, PageOrientation.Landscape, 25));

PageDimensions pgDim = new(PageSize.Letter, PageOrientation.Portrait);
pgDim.BottomMargin = 50;
pgDim.TopMargin = 50;
pgDim.LeftMargin = 35;
pgDim.RightMargin = 35;

document.Pages.Add(new Page(pgDim));
document.Pages.Add(new Page(100, 200));

document.Draw(outputPath);
Dim document As New Document()

document.Pages.Add(New Page(PageSize.Legal))
document.Pages.Add(New Page(PageSize.Letter, PageOrientation.Landscape, 25))

Dim pgDim As New PageDimensions(PageSize.Letter, PageOrientation.Portrait)
pgDim.BottomMargin = 50
pgDim.TopMargin = 50
pgDim.LeftMargin = 35
pgDim.RightMargin = 35

document.Pages.Add(New Page(pgDim))
document.Pages.Add(New Page(100, 200))
document.Draw(outputPath)

Pages Figure 1. A document with several pages of different dimensions.

In this topic