Xamarin.Forms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfAlignmentStyle

    Show / Hide Table of Contents

    Class PdfAlignmentStyle

    Specifies how the page template is aligned relative to the template area.

    Inheritance
    System.Object
    PdfAlignmentStyle
    Namespace: Syncfusion.Pdf
    Assembly: Syncfusion.Pdf.Portable.dll
    Syntax
    public sealed class PdfAlignmentStyle : Enum
    Remarks

    This enumeration is used in PdfPageTemplateElement class.

    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;
    doc.Save("Template.pdf");
    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
    doc.Save("Template.pdf")
    doc.Close(True)

    Fields

    BottomCenter

    The template is bottom center aligned.

    Declaration
    public const PdfAlignmentStyle BottomCenter
    Field Value
    Type Description
    PdfAlignmentStyle

    BottomLeft

    The template is bottom left aligned.

    Declaration
    public const PdfAlignmentStyle BottomLeft
    Field Value
    Type Description
    PdfAlignmentStyle

    BottomRight

    The template is bottom right aligned.

    Declaration
    public const PdfAlignmentStyle BottomRight
    Field Value
    Type Description
    PdfAlignmentStyle

    MiddleCenter

    The template is middle center aligned.

    Declaration
    public const PdfAlignmentStyle MiddleCenter
    Field Value
    Type Description
    PdfAlignmentStyle

    MiddleLeft

    The template is middle left aligned.

    Declaration
    public const PdfAlignmentStyle MiddleLeft
    Field Value
    Type Description
    PdfAlignmentStyle

    MiddleRight

    The template is middle right aligned.

    Declaration
    public const PdfAlignmentStyle MiddleRight
    Field Value
    Type Description
    PdfAlignmentStyle

    None

    Specifies no alignment.

    Declaration
    public const PdfAlignmentStyle None
    Field Value
    Type Description
    PdfAlignmentStyle

    TopCenter

    The template is top center aligned.

    Declaration
    public const PdfAlignmentStyle TopCenter
    Field Value
    Type Description
    PdfAlignmentStyle

    TopLeft

    The template is top left aligned.

    Declaration
    public const PdfAlignmentStyle TopLeft
    Field Value
    Type Description
    PdfAlignmentStyle

    TopRight

    The template is top right aligned.

    Declaration
    public const PdfAlignmentStyle TopRight
    Field Value
    Type Description
    PdfAlignmentStyle

    value__

    Declaration
    public int value__
    Field Value
    Type Description
    System.Int32

    See Also

    PdfDocument
    PdfPage
    PdfFont
    PdfFontFamily
    PdfBrushes
    PdfPageNumberField
    PdfPageCountField
    PdfCompositeField
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved