Class PdfStringFormat
Represents the text layout information on PDF
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public sealed class PdfStringFormat : ICloneable
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)
Constructors
PdfStringFormat()
Initializes a new instance of the PdfStringFormat class.
Declaration
public PdfStringFormat()
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)
PdfStringFormat(PdfTextAlignment)
Initializes a new instance of the PdfStringFormat class with horizontal alignment of a text
Declaration
public PdfStringFormat(PdfTextAlignment alignment)
Parameters
Type | Name | Description |
---|---|---|
PdfTextAlignment | alignment | The PdfTextAlignment represents the horizontal alignment of a text in PDF . |
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(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(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)
PdfStringFormat(PdfTextAlignment, PdfVerticalAlignment)
Initializes a new instance of the PdfStringFormat class with horizontal and vertical alignment
Declaration
public PdfStringFormat(PdfTextAlignment alignment, PdfVerticalAlignment lineAlignment)
Parameters
Type | Name | Description |
---|---|---|
PdfTextAlignment | alignment | The PdfTextAlignment represents the horizontal alignment of a text in PDF . |
PdfVerticalAlignment | lineAlignment | The PdfVerticalAlignment represents the vertical alignment of a text in PDF |
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(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//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(PdfTextAlignment.Center, PdfVerticalAlignment.Middle)
'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)
PdfStringFormat(String)
Initializes a new instance of the PdfStringFormat class with column format
Declaration
public PdfStringFormat(string columnFormat)
Parameters
Type | Name | Description |
---|---|---|
System.String | columnFormat | The column format. |
Properties
Alignment
Gets or sets the horizontal text alignment
Declaration
public PdfTextAlignment Alignment { get; set; }
Property Value
Type | Description |
---|---|
PdfTextAlignment | The PdfTextAlignment represents the horizontal alignment of a text in PDF |
Remarks
Default value: PdfTextAlignment.Left
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)
CharacterSpacing
Gets or sets value that indicates a size among the characters in the text. When the glyph for each character in the string is rendered, this value is added to the glyph�s displacement.
Declaration
public float CharacterSpacing { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
Default value is 0.
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set character spacing.
format.CharacterSpacing = 1;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set character spacing.
format.CharacterSpacing = 1
'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)
ClipPath
Gets or sets a value indicating whether the text should be a part of the clipping path.
Declaration
public bool ClipPath { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set character spacing.
format.CharacterSpacing = 1;
//Set clip path.
format.ClipPath = true;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set character spacing.
format.CharacterSpacing = 1
'Set clip path.
format.ClipPath = True
'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)
ComplexScript
Gets or sets the complex text layout rendering.
Declaration
public bool ComplexScript { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
EnableBaseline
Gets or sets the baseline for line alignment.
Declaration
public bool EnableBaseline { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 PdfTrueTypeFont(new Font("Tahoma",8), 8);
PdfFont font1 = new PdfTrueTypeFont(new Font("Calibri",20), 20);
PdfFont font2 = new PdfStandardFont(PdfFontFamily.Helvetica,16);
PdfFont font3 = new PdfTrueTypeFont(new Font("Arial",25), 25);
//Create a new PDF string format instance.
PdfStringFormat format = new PdfStringFormat();
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Bottom;
//Set baseline for line alignment
format.EnableBaseline = true;
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, PdfBrushes.Black, new PointF(0, 50), format);
graphics.DrawString("Hello World!", font1, PdfBrushes.Black, new PointF(65, 50), format);
graphics.DrawString("Hello World!", font2, PdfBrushes.Black, new PointF(220, 50), format);
graphics.DrawString("Hello World!", font3, PdfBrushes.Black, new PointF(320, 50), 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 PdfTrueTypeFont(new Font("Tahoma",8), 8);
Dim font1 As PdfFont = New PdfTrueTypeFont(new Font("Calibri",20), 20);
Dim font2 As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica,16);
Dim font3 As PdfFont = New PdfTrueTypeFont(new Font("Arial",25), 25);
'Create a new PDF string format instance.
Dim format As PdfStringFormat = New PdfStringFormat()
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Bottom;
'Set baseline for line alignment
format.EnableBaseline = true;
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, PdfBrushes.Black, New PointF(0, 50), format);
graphics.DrawString("Hello World!", font1, PdfBrushes.Black, New PointF(65, 50), format);
graphics.DrawString("Hello World!", font2, PdfBrushes.Black, New PointF(220, 50), format);
graphics.DrawString("Hello World!", font3, PdfBrushes.Black, New PointF(320, 50), format);
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
EnableNewLineIndent
Gets or sets whether the new line indent is enabled or not.
Declaration
public bool EnableNewLineIndent { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set paragraph indent.
format.ParagraphIndent = 2.1f;
//Enable/Diable new line indent.
format.EnableNewLineIndent = false;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set paragraph indent.
format.ParagraphIndent = 2.1F
'Enable/Diable new line indent.
format.EnableNewLineIndent = False
'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)
LineAlignment
Gets or sets the vertical text alignment.
Declaration
public PdfVerticalAlignment LineAlignment { get; set; }
Property Value
Type | Description |
---|---|
PdfVerticalAlignment | The PdfVerticalAlignment represents the vertical alignment of a text in PDF |
Remarks
Default Value: PdfVerticalAlignment.Top
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'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)
LineLimit
Gets or sets a value indicating whether [line limit].
Declaration
public bool LineLimit { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set character spacing.
format.CharacterSpacing = 1;
//Set clip path.
format.ClipPath = true;
//Set line limit.
format.LineLimit = true;
//Set line spacing.
format.LineSpacing = 1.1f;
//Set measure trailing spaces.
format.MeasureTrailingSpaces = true;
//Set no clip
format.NoClip = true;
//Set paragraph indent.
format.ParagraphIndent = 2.1f;
//Set right to left.
format.RightToLeft = false;
//Set word spacing.
format.WordSpacing = 1.5f;
//Set word wrap type.
format.WordWrap = PdfWordWrapType.Word;
//Set sub/super script type.
format.SubSuperScript = PdfSubSuperScript.SubScript;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set character spacing.
format.CharacterSpacing = 1
'Set clip path.
format.ClipPath = True
'Set line limit.
format.LineLimit = True
'Set line spacing.
format.LineSpacing = 1.1F
'Set measure trailing spaces.
format.MeasureTrailingSpaces = True
'Set no clip
format.NoClip = True
'Set paragraph indent.
format.ParagraphIndent = 2.1F
'Set right to left.
format.RightToLeft = False
'Set word spacing.
format.WordSpacing = 1.5F
'Set word wrap type.
format.WordWrap = PdfWordWrapType.Word
'Set sub/super script type.
format.SubSuperScript = PdfSubSuperScript.SubScript
'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)
LineSpacing
Gets or sets value that indicates the vertical distance between the baselines of adjacent lines of text.
Declaration
public float LineSpacing { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
Default value is 0.
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set line spacing.
format.LineSpacing = 1.1f;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set line spacing.
format.LineSpacing = 1.1F
'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)
MeasureTrailingSpaces
Gets or sets a value indicating whether [measure trailing spaces].
Declaration
public bool MeasureTrailingSpaces { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set character spacing.
format.CharacterSpacing = 1;
//Set clip path.
format.ClipPath = true;
//Set line limit.
format.LineLimit = true;
//Set line spacing.
format.LineSpacing = 1.1f;
//Set measure trailing spaces.
format.MeasureTrailingSpaces = true;
//Set no clip
format.NoClip = true;
//Set paragraph indent.
format.ParagraphIndent = 2.1f;
//Set right to left.
format.RightToLeft = false;
//Set word spacing.
format.WordSpacing = 1.5f;
//Set word wrap type.
format.WordWrap = PdfWordWrapType.Word;
//Set sub/super script type.
format.SubSuperScript = PdfSubSuperScript.SubScript;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set character spacing.
format.CharacterSpacing = 1
'Set clip path.
format.ClipPath = True
'Set line limit.
format.LineLimit = True
'Set line spacing.
format.LineSpacing = 1.1F
'Set measure trailing spaces.
format.MeasureTrailingSpaces = True
'Set no clip
format.NoClip = True
'Set paragraph indent.
format.ParagraphIndent = 2.1F
'Set right to left.
format.RightToLeft = False
'Set word spacing.
format.WordSpacing = 1.5F
'Set word wrap type.
format.WordWrap = PdfWordWrapType.Word
'Set sub/super script type.
format.SubSuperScript = PdfSubSuperScript.SubScript
'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)
NoClip
Gets or sets a value indicating whether [no clip].
Declaration
public bool NoClip { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set character spacing.
format.CharacterSpacing = 1;
//Set clip path.
format.ClipPath = true;
//Set line limit.
format.LineLimit = true;
//Set line spacing.
format.LineSpacing = 1.1f;
//Set measure trailing spaces.
format.MeasureTrailingSpaces = true;
//Set no clip
format.NoClip = true;
//Set paragraph indent.
format.ParagraphIndent = 2.1f;
//Set right to left.
format.RightToLeft = false;
//Set word spacing.
format.WordSpacing = 1.5f;
//Set word wrap type.
format.WordWrap = PdfWordWrapType.Word;
//Set sub/super script type.
format.SubSuperScript = PdfSubSuperScript.SubScript;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set character spacing.
format.CharacterSpacing = 1
'Set clip path.
format.ClipPath = True
'Set line limit.
format.LineLimit = True
'Set line spacing.
format.LineSpacing = 1.1F
'Set measure trailing spaces.
format.MeasureTrailingSpaces = True
'Set no clip
format.NoClip = True
'Set paragraph indent.
format.ParagraphIndent = 2.1F
'Set right to left.
format.RightToLeft = False
'Set word spacing.
format.WordSpacing = 1.5F
'Set word wrap type.
format.WordWrap = PdfWordWrapType.Word
'Set sub/super script type.
format.SubSuperScript = PdfSubSuperScript.SubScript
'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)
ParagraphIndent
Gets or sets the indent of the first line in the paragraph.
Declaration
public float ParagraphIndent { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set paragraph indent.
format.ParagraphIndent = 2.1f;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set paragraph indent.
format.ParagraphIndent = 2.1F
'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)
RightToLeft
Gets or sets the value that indicates text direction mode.
Declaration
[Obsolete("Please use PdfStringFormat.TextDirection (eg:TextDirection = PdfTextDirection.RightToLeft) instead")]
public bool RightToLeft { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
Note, that this property doesn't change any alignment of the text. Alignment property should be set manually to align the text. This property just enables or disables support of right to left approach. If the value is False, the text won't be checked for right to left symbols occurrence. This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
format.RightToLeft = false;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set right to left.
format.RightToLeft = False
'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)
SubSuperScript
Gets or sets value indicating whether the text is in subscript or superscript mode.
Declaration
public PdfSubSuperScript SubSuperScript { get; set; }
Property Value
Type | Description |
---|---|
PdfSubSuperScript | The PdfSubSuperScript indicating whether the text is in subscript or superscript mode |
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set sub/super script type.
format.SubSuperScript = PdfSubSuperScript.SubScript;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set sub/super script type.
format.SubSuperScript = PdfSubSuperScript.SubScript
'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)
TextDirection
Gets or sets the value that indicates text direction.
Declaration
public PdfTextDirection TextDirection { get; set; }
Property Value
Type | Description |
---|---|
PdfTextDirection |
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
format.TextDirection = PdfTextDirection.RightToLeft;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set right to left.
format.TextDirection = PdfTextDirection.RightToLeft
'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)
WordSpacing
Gets or sets value that indicates a size among the words in the text. Word spacing works the same way as character spacing but applies only to the space character, code 32.
Declaration
public float WordSpacing { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
Default value is 0.
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set word spacing.
format.WordSpacing = 1.5f;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set word spacing.
format.WordSpacing = 1.5F
'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)
WordWrap
Gets or sets value indicating type of the text wrapping.
Declaration
public PdfWordWrapType WordWrap { get; set; }
Property Value
Type | Description |
---|---|
PdfWordWrapType | The PdfWordWrapType indicating type of the text wrapping |
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;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Set character spacing.
format.CharacterSpacing = 1;
//Set clip path.
format.ClipPath = true;
//Set line limit.
format.LineLimit = true;
//Set line spacing.
format.LineSpacing = 1.1f;
//Set measure trailing spaces.
format.MeasureTrailingSpaces = true;
//Set no clip
format.NoClip = true;
//Set paragraph indent.
format.ParagraphIndent = 2.1f;
//Set right to left.
format.RightToLeft = false;
//Set word spacing.
format.WordSpacing = 1.5f;
//Set word wrap type.
format.WordWrap = PdfWordWrapType.Word;
//Set sub/super script type.
format.SubSuperScript = PdfSubSuperScript.SubScript;
//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
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
'Set character spacing.
format.CharacterSpacing = 1
'Set clip path.
format.ClipPath = True
'Set line limit.
format.LineLimit = True
'Set line spacing.
format.LineSpacing = 1.1F
'Set measure trailing spaces.
format.MeasureTrailingSpaces = True
'Set no clip
format.NoClip = True
'Set paragraph indent.
format.ParagraphIndent = 2.1F
'Set right to left.
format.RightToLeft = False
'Set word spacing.
format.WordSpacing = 1.5F
'Set word wrap type.
format.WordWrap = PdfWordWrapType.Word
'Set sub/super script type.
format.SubSuperScript = PdfSubSuperScript.SubScript
'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)
Methods
Clone()
Clones the object.
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.Object | The new created object. |
Examples
PdfStringFormat format = new PdfStringFormat();
//Set the text alignment.
format.Alignment = PdfTextAlignment.Center;
//Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle;
//Clone the string format.
PdfStringFormat format1 = format.Clone() as PdfStringFormat;
'Create a new PDF string format instance.
Dim format As New PdfStringFormat()
'Set the text alignment.
format.Alignment = PdfTextAlignment.Center
'Set the line alignment.
format.LineAlignment = PdfVerticalAlignment.Middle
'Clone the string format.
Dim format1 As PdfStringFormat = TryCast(format.Clone(), PdfStringFormat)