Class TextAlign
Specifies how text in a
Inheritance
System.Object
TextAlign
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.UWP.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 |
---|
TextAlign |
Justify
The text is justified.
Declaration
public const TextAlign Justify
Field Value
Type |
---|
TextAlign |
Left
The text is aligned to the left.
Declaration
public const TextAlign Left
Field Value
Type |
---|
TextAlign |
Right
The text is aligned to the right.
Declaration
public const TextAlign Right
Field Value
Type |
---|
TextAlign |