Xamarin.Android

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

    Show / Hide Table of Contents

    Class TextAlign

    Specifies how text in a is horizontally aligned.

    Inheritance
    System.Object
    TextAlign
    Namespace: Syncfusion.Pdf.Graphics
    Assembly: Syncfusion.Pdf.Portable.dll
    Syntax
    public sealed class TextAlign : Enum
    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Add a page to the document.
    PdfPage page = doc.Pages.Add();
    //Create PDF graphics for the page.
    PdfGraphics graphics = page.Graphics;
    //Set the font.
    PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
    //Simple HTML content
    string htmlText = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files ";
    //Create new PDF HTML text element.
    PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
    //Set text align.
    htmlTextElement.TextAlign = TextAlign.Left;
    //Set html text.
    htmlTextElement.HTMLText = htmlText;
    //Set font.
    htmlTextElement.Font = font;
    //Format Layout.
    PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
    format.Layout = PdfLayoutType.Paginate;
    format.Break = PdfLayoutBreakType.FitPage;
    //Draw htmlString to PDF page.
    htmlTextElement.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format);
    //Save the document.
    doc.Save("Output.pdf");
    //Close the document.
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As New PdfDocument()
    'Add a page to the document.
    Dim page As PdfPage = doc.Pages.Add()
    'Create PDF graphics for the page.
    Dim graphics As PdfGraphics = page.Graphics
    'Set the font.
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
    'Simple HTML content
    Dim htmlText As String = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files "
    'Create new PDF HTML text element.
    Dim htmlTextElement As New PdfHTMLTextElement()
    'Set text align
    htmlTextElement.TextAlign = TextAlign.Left
    'Set html text.
    htmlTextElement.HTMLText = htmlText
    'Set font.
    htmlTextElement.Font = font
    'Format Layout.
    Dim format As New PdfMetafileLayoutFormat()
    format.Layout = PdfLayoutType.Paginate
    format.Break = PdfLayoutBreakType.FitPage
    'Draw htmlString to PDF page.
    htmlTextElement.Draw(page, New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format)
    'Save the document.
    doc.Save("Output.pdf")
    'Close the document.
    doc.Close(True)

    Fields

    Center

    The text is aligned in the center.

    Declaration
    public const TextAlign Center
    Field Value
    Type Description
    TextAlign

    Justify

    The text is justified.

    Declaration
    public const TextAlign Justify
    Field Value
    Type Description
    TextAlign

    Left

    The text is aligned to the left.

    Declaration
    public const TextAlign Left
    Field Value
    Type Description
    TextAlign

    Right

    The text is aligned to the right.

    Declaration
    public const TextAlign Right
    Field Value
    Type Description
    TextAlign

    value__

    Declaration
    public int value__
    Field Value
    Type Description
    System.Int32
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved