Class PdfTextAlignment
Specifies the type of horizontal text alignment.
Inheritance
System.Object
PdfTextAlignment
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public sealed class PdfTextAlignment : Enum
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Create a new PDF font instance.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create a new PDF string format instance.
PdfStringFormat format = new PdfStringFormat();
//Set the text alignment.
format.Alignment = PdfTextAlignment.Center;
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, PdfBrushes.Black, new RectangleF(0, 0, 200, 100), format);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Create a new PDF font instance.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Create a new PDF string format instance.
Dim format As PdfStringFormat = New PdfStringFormat()
'Set the text alignment.
format.Alignment = PdfTextAlignment.Center
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, PdfBrushes.Black, New RectangleF(0, 0, 200, 100), format);
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Fields
Center
Specifies the text is aligned to Center.
Declaration
public const PdfTextAlignment Center
Field Value
Type |
---|
PdfTextAlignment |
Justify
Specifies the text as Justified text.
Declaration
public const PdfTextAlignment Justify
Field Value
Type |
---|
PdfTextAlignment |
Left
Specifies the text is aligned to Left.
Declaration
public const PdfTextAlignment Left
Field Value
Type |
---|
PdfTextAlignment |
Right
Specifies the text is aligned to Right.
Declaration
public const PdfTextAlignment Right
Field Value
Type |
---|
PdfTextAlignment |