cete.dynamicpdf.template
Template
- Namespace: ceTe.DynamicPDF
- Assemblies: DynamicPDF.NETFramework40.dll, DynamicPDF.NETStandard20.dll
Represents a document or section template.
public class Template
Public Class Template
Inheritance: Object → Template
Derived: EvenOddTemplate, HeaderFooterTemplate
Licensing
This class is a DynamicPDF Generator Community Edition feature.
Examples
This example shows how to create a template and add it to the document.
Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Module MyModule
Sub Main()
' Create a PDF Document
Dim MyDocument As Document = New Document
' Add 5 blank pages to the document
MyDocument.Pages.Add(New Page(PageSize.Letter))
MyDocument.Pages.Add(New Page(PageSize.Letter))
MyDocument.Pages.Add(New Page(PageSize.Letter))
MyDocument.Pages.Add(New Page(PageSize.Letter))
MyDocument.Pages.Add(New Page(PageSize.Letter))
' Create a template and add elements to it
Dim MyTemplate As Template = New Template
MyTemplate.Elements.Add(New Label("Header", 0, 0, 200, 12))
MyTemplate.Elements.Add(New Label("Footer", 0, 680, 200, 12))
' Add the template to the document
MyDocument.Template = MyTemplate
' Save the PDF document
MyDocument.Draw("C:\MyDocument.pdf")
End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
public class Example
{
public static void CreatePDF(string outputPath)
{
// Create a PDF Document
Document document = new Document();
// Add 5 blank pages to the document
document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));
// Create a template and add elements to it
Template template = new Template();
template.Elements.Add(new Label("Header", 0, 0, 200, 12));
template.Elements.Add(new Label("Footer", 0, 680, 200, 12));
// Add the template to the document
document.Template = template;
// Save the PDF document
document.Draw(outputPath);
}
}
Remarks
See the Templates topic for more on templates.
Constructors
Template()
Initializes a new instance of the Template class.
public Template()
Public Sub New ()
Properties
Elements
Gets the page elements that will be applied by the template to all pages.
public Group Elements { get; }
Public Property Elements As Group
Property Value
Methods
Draw(PageWriter)
Draws the template's page elements to the given PageWriter object.
public void Draw(PageWriter writer)
Sub Draw(writer As PageWriter)
Parameters
- writer: PageWriter
PageWriter object to receive the template's output.
Equals(Object)
Determines whether the specified Object is equal to the current Object . (Inherited from Object)
public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean
Parameters
- obj: Object
The Object to compare with the current Object .
Returns
true if the specified Object is equal to the current Object ; otherwise, false.
GetHashCode()
Serves as a hash function for a particular type. (Inherited from Object)
public int GetHashCode()
Function GetHashCode() As Integer
Returns
A hash code for the current Object .
GetType()
Gets the Type of the current instance. (Inherited from Object)
public Type GetType()
Function GetType() As Type
Returns
The Type instance that represents the exact runtime type of the current instance.
HasPageElements(Int32)
Returns a value indicating if the template has page elements for the given page.
public bool HasPageElements(int pageNumber)
Function HasPageElements(pageNumber As Integer) As Boolean
Parameters
- pageNumber: Int32
Page number to test.
Returns
A Boolean value indicating if there are page elements.
ToString()
Returns a String that represents the current Object . (Inherited from Object)
public string ToString()
Function ToString() As String
Returns
A String that represents the current Object .