Click or drag to resize
Pdf Library for .NET

Page Settings

Select.Pdf can be used to control how a page looks like when it is added to a pdf document. The most important properties of a pdf page are:

  • Page size

  • Page orientation

  • Page margins

Page size

SelectPdf supports the following standard page sizes:

  • A0 to A10

  • B0 to B5

  • ArchA to ArchE

  • Letter, HalfLetter, Letter11x17, Note, Flsa, Ledger

Pages with custom page sizes can also be created using Select.Pdf.

Page orientation

SelectPdf supports the following page orientations:

  • Portrait

  • Landscape

Page margins

Page margins can be set using PdfMargins object.

Adding a page to a pdf document

The page settings described above can be set when a new page is added to the pdf document.

// add a new page to the document 
// (with specific page size, margins and orientation)
PdfPage page = doc.AddPage(PdfCustomPageSize.A4, new PdfMargins(0f), PdfPageOrientation.Portrait);

The page size and orientation can also be modified directly on PdfPage object, but the page margins can be set only on the PdfDocument object, using either AddPage(PdfMargins) method or the Margins property.

If there is a previous page in the pages collection when a new page is added with no parameters specified, the orientation and size are inherited from that page, otherwise a first page with the default A4 size and Portrait orientation is created. The page margins are inherited from the default pdf document margins specified in Margins property.

Sample Code

The sample code below create a first page with no margins, size A4 and Portrait orientation and a second page with 20pt for all margins, Letter size and Landscape orientation.

// create a new pdf document
PdfDocument doc = new PdfDocument();

// create a new pdf font
PdfFont font = doc.AddFont(PdfStandardFont.Helvetica);
font.Size = 18;

// add a new page to the document 
// (with specific page size, margins and orientation)
PdfPage page = doc.AddPage(PdfCustomPageSize.A4, new PdfMargins(0f), PdfPageOrientation.Portrait);

// create a new text element and add it to the page
PdfTextElement text = new PdfTextElement(0, 0, Helper.SomeText(), font);
page.Add(text);

// add a new page to the document
// (with specific page size, margins and orientation)
PdfPage page2 = doc.AddPage(PdfCustomPageSize.Letter, new PdfMargins(20f), PdfPageOrientation.Landscape);

// create a new text element and add it to the page
PdfTextElement text2 = new PdfTextElement(0, 0, Helper.SomeText(), font);
page2.Add(text2);

// save pdf document
doc.Save(file);

// close pdf document
doc.Close();
See Also