menu

WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Enum PdfDockStyle - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Enum PdfDockStyle

    Specifies the docking style of the page template.

    Namespace: Syncfusion.Pdf
    Assembly: Syncfusion.Pdf.Base.dll
    Syntax
    public enum PdfDockStyle
    Remarks

    This enumeration is used in PdfPageTemplateElement class. To know more details about PdfPageTemplateElement refer this link.

    Examples
    //Create a PDF document
    PdfDocument doc = new PdfDocument();
    //Create a page
    PdfPage page = doc.Pages.Add();
    RectangleF rect = new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height);
    //Create a page template
    PdfPageTemplateElement footer = new PdfPageTemplateElement(rect);
    //set the dock style
    footer.Dock = PdfDockStyle.Right;
    //Set the template alignment as top right
    footer.Alignment = PdfAlignmentStyle.TopRight;
    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.Right = footer;
    //Save the document
    doc.Save("Template.pdf");
    //Close the document
    doc.Close(true);
    'Create a PDF document
    Dim doc As New PdfDocument()
    'Create a page
    Dim page As PdfPage = doc.Pages.Add()
    Dim rect As New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height)
    'Create a page template
    Dim footer As New PdfPageTemplateElement(rect)
    'set the dock style
    footer.Dock = PdfDockStyle.Right
    'Set the template alignment as top right
    footer.Alignment = PdfAlignmentStyle.TopRight
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 8)
    Dim brush As New PdfSolidBrush(Color.Gray)
    'Create page number field
    Dim pageNumber As New PdfPageNumberField(font, brush)
    'Create page count field
    Dim count As New PdfPageCountField(font, brush)
    Dim compositeField As 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.Right = footer
    'Save the document
    doc.Save("Template.pdf")
    'Close the document
    doc.Close(True)

    Fields

    Name Description
    Bottom

    The page template edge is docked to the bottom page's side.

    Fill

    The page template stretch on full page.

    Left

    The page template edge is docked to the left page's side.

    None

    The page template is not docked.

    Right

    The page template edge is docked to the right page's side.

    Top

    The page template edge is docked to the top page's side.

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