Click or drag to resize
Pdf Library for .NET

PdfTemplate Class

Represents a template in a pdf document. A template contains elements that are repeated on more than one page of the pdf document.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfCanvas
    SelectPdf.UniversalPdfTemplate

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public class PdfTemplate : PdfCanvas

The PdfTemplate type exposes the following members.

Properties
 NameDescription
Public propertyAnchoring Gets or sets the template anchoring settings inside the pdf page.
Public propertyBackground Controls whether the template is rendered behind the page main content. The default is false.
Public propertyBounds Gets or sets the template bounds rectangle. Has no effect for the default header / footer.
Public propertyClientRectangle Gets the drawable area of the canvas. The page margins (and, for a page, the document header and footer) are excluded.
(Inherited from PdfCanvas)
Public propertyDisplayOnEvenPages Controls the visibility of the template on the even numbered pages of the pdf document.
Public propertyDisplayOnFirstPage Controls the visibility of the template on the first page of the pdf document. This property has priority over DisplayOnOddPages. The default value is true.
Public propertyDisplayOnOddPages Controls the visibility of the template on the odd numbered pages of the pdf document.
Public propertyDocking Gets or sets the template docking style inside the pdf page.
Public propertyFirstPageNumber Controls the page number for the first page being rendered. The default is 1.
Public propertyForeground Controls whether the template is rendered in front of the page main content. The default is true.
Public propertyHeight Gets or sets the height for a custom template. Has no effect for the default header / footer.
Public propertyLFN Gets or sets the path of the diagnostic log file written while the html content added to this template is rendered. An html element that has a log file of its own keeps it. When unset, a template obtained through the document's Header, Footer or AddTemplate(Single, Single) uses the document's log file. When none is set, no log is written.
Public propertyTotalPagesOffset Controls the total number of pages offset in the pdf document.
Public propertyWidth Gets or sets the width for a custom template. Has no effect for the default header / footer.
Top
Methods
 NameDescription
Public methodCode exampleAdd Adds a pdf element to the template.
(Overrides PdfCanvasAdd(PdfPageElement))
Public methodCode exampleAddAsync(PdfPageElement) Adds a pdf page element to the canvas without waiting for it to be rendered.
(Inherited from PdfCanvas)
Public methodAddAsync(PdfPageElement, CancellationToken) Adds a pdf page element to the canvas without waiting for it to be rendered, stopping when the specified token is cancelled.
(Inherited from PdfCanvas)
Public methodMeasureString Measures the size of the specified string when rendered with the specified font.
(Inherited from PdfCanvas)
Top
Example
PdfDocument doc = new PdfDocument();
doc.AddPage();
PdfTemplate header = doc.Templates.Add(doc.Pages[0].PageSize.Width, 40);
header.Add(new PdfTextElement(0, 10, "CONFIDENTIAL",
    PdfFont.CreateStandardFont(PdfStandardFont.HelveticaBold, 12),
    new PdfColor(0, 0, 0)));
doc.Templates.Header = header;
doc.Save("with-header.pdf");
See Also