Enum TextAlign
Specifies how text in a Syncfusion.Pdf.Graphics.RichTextBoxExt is horizontally aligned.
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public enum TextAlign
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
Name | Description |
---|---|
Center | The text is aligned in the center. |
Justify | The text is justified. |
Left | The text is aligned to the left. |
Right | The text is aligned to the right. |