menu

UWP

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfDocumentTemplate - UWP API Reference | Syncfusion

    Show / Hide Table of Contents

    Class PdfDocumentTemplate

    Encapsulates a page template for all the pages in the document.

    Inheritance
    System.Object
    PdfDocumentTemplate
    PdfSectionTemplate
    Namespace: Syncfusion.Pdf
    Assembly: Syncfusion.Pdf.UWP.dll
    Syntax
    public class PdfDocumentTemplate : Object
    Examples
    //Create a PDF document.
    PdfDocument doc = new PdfDocument();
    //Creates a new page and adds it as the last page of the document
    PdfPage page = doc.Pages.Add();
    RectangleF rect = new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height);
    //Creates a new page and adds it as the last page of the document template
    PdfPageTemplateElement footer = new PdfPageTemplateElement(rect);
    PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8);
    PdfSolidBrush brush = new PdfSolidBrush(Color.Gray);
    //Create page number field
    PdfPageNumberField pageNumber = new PdfPageNumberField(font, brush);
    //Create page count field
    PdfPageCountField count = new PdfPageCountField(font, brush);
    PdfCompositeField compositeField = new PdfCompositeField(font, brush, "Page {0} of {1}", pageNumber, count);
    compositeField.Bounds = footer.Bounds;
    compositeField.Draw(footer.Graphics, new PointF(40, footer.Height - 50));          
    //Add the footer template at the bottom
    doc.Template.Bottom = footer;
    //Save the document
    doc.Save("Template.pdf");
    //Close the document
    doc.Close(true);
    'Create a PDF document
    Dim doc As PdfDocument = New PdfDocument()
    'Create a page
    Dim page As PdfPage = doc.Pages.Add()
    Dim rect As RectangleF = New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height)
    'Create a page template
    Dim footer As PdfPageTemplateElement = New PdfPageTemplateElement(rect)
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 8)
    Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Gray)
    'Create page number field
    Dim pageNumber As PdfPageNumberField = New PdfPageNumberField(font, brush)
    'Create page count field
    Dim count As PdfPageCountField = New PdfPageCountField(font, brush)
    Dim compositeField As PdfCompositeField = New PdfCompositeField(font, brush, "Page {0} of {1}", pageNumber, count)
    compositeField.Bounds = footer.Bounds
    compositeField.Draw(footer.Graphics, New PointF(40, footer.Height - 50))
    'Add the footer template at the bottom
    doc.Template.Bottom = footer
    doc.Save("Template.pdf")
    'Close the document
    doc.Close(True)

    Constructors

    PdfDocumentTemplate()

    Initializes a new instance of the PdfDocumentTemplate class.

    Declaration
    public PdfDocumentTemplate()

    Properties

    Bottom

    Gets or sets a bottom page template.

    Declaration
    public PdfPageTemplateElement Bottom { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    EvenBottom

    Gets or sets a bottom page template using on the even pages.

    Declaration
    public PdfPageTemplateElement EvenBottom { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    EvenLeft

    Gets or sets a left page template using on the even pages.

    Declaration
    public PdfPageTemplateElement EvenLeft { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    EvenRight

    Gets or sets a right page template using on the even pages.

    Declaration
    public PdfPageTemplateElement EvenRight { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    EvenTop

    Gets or sets a top page template using on the even pages.

    Declaration
    public PdfPageTemplateElement EvenTop { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    Left

    Gets or sets a left page template.

    Declaration
    public PdfPageTemplateElement Left { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    OddBottom

    Gets or sets a bottom page template using on the odd pages.

    Declaration
    public PdfPageTemplateElement OddBottom { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    OddLeft

    Gets or sets a left page template using on the odd pages.

    Declaration
    public PdfPageTemplateElement OddLeft { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    OddRight

    Gets or sets a right page template using on the odd pages.

    Declaration
    public PdfPageTemplateElement OddRight { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    OddTop

    Gets or sets a top page template using on the odd pages.

    Declaration
    public PdfPageTemplateElement OddTop { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    Right

    Gets or sets a right page template.

    Declaration
    public PdfPageTemplateElement Right { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    Stamps

    Gets a collection of stamp elements.

    Declaration
    public PdfStampCollection Stamps { get; }
    Property Value
    Type Description
    PdfStampCollection

    The PdfStampCollection,a collection of stamps that are applied to the page templates.

    Top

    Gets or sets a top page template.

    Declaration
    public PdfPageTemplateElement Top { get; set; }
    Property Value
    Type Description
    PdfPageTemplateElement

    The PdfPageTemplateElement to draw into the PDF page

    Extension Methods

    DateTimeExtension.ToDateTime(Object)

    See Also

    PdfDocument
    PdfPage
    PdfFont
    PdfBrush
    PdfPageTemplateElement
    PdfPageNumberField
    PdfPageCountField
    PdfCompositeField
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved