Click or drag to resize

PdfPage Class

The PdfPage class represents a page in the PDF document. A PdfPage object is created with the AddPage and InsertPage methods of the Document class. When the AddPage method is called without parameters, a page with the default margins, size and orientation is created. The margins are inherited from the Margins property. The default orientation is Portrait for the first page of the document, and the orientation of the previous page otherwise. The default size is A4 for the first page, and the size of the previous page otherwise. Each of these settings can be given to the other overloads of the AddPage method. A page can have its own size and orientation, so a document can mix page sizes.

A page renders the page elements added to it with AddElement(PageElement). Its RotationAngle property rotates the page when it is displayed, ShowHeaderTemplate and ShowFooterTemplate hide the document header or footer on that page, and CustomHeaderTemplate and CustomFooterTemplate replace them on that page only.

Sample Code

The sample code below opens an existing PDF document, adds a new page (size Letter, 5 points margins) and saves the document back to the file:

using (Document existingDoc = new Document(pdfFilePath))
{
    PdfPage newPage = existingDoc.AddPage(PageSize.Letter, new Margins(5));
    existingDoc.Save(pdfFilePath);
}
See Also

Other Resources

Document Class
Overview