Class PdfFont
- Namespace
- Syncfusion.Pdf.Graphics
- Assembly
- Syncfusion.Pdf.Portable.dll
Defines a particular format for text, including font face, size, and style attributes.
public abstract class PdfFont
- Inheritance
-
PdfFont
- Derived
- Inherited Members
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);
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty);
//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)
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Constructors
PdfFont(float)
Initializes a new instance of the PdfFont class.
protected PdfFont(float size)
Parameters
size
floatThe size.
PdfFont(float, PdfFontStyle)
Initializes a new instance of the PdfFont class.
protected PdfFont(float size, PdfFontStyle style)
Parameters
size
floatThe size.
style
PdfFontStyleThe style.
Fields
s_syncObject
Synchronization object.
protected static object s_syncObject
Field Value
Properties
Bold
Gets a value indicating whether this PdfFont is bold.
public bool Bold { get; }
Property Value
- bool
true
if bold; otherwise,false
.
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);
//Get font Name.
string fontName = font.Name;
//Get font size.
float fontSize = font.Size;
//Get font height.
float fontHeight = font.Height;
//Get the font style.
PdfFontStyle style = font.Style;
StringBuilder builder = new StringBuilder();
builder.AppendLine("Font Name: " + fontName);
builder.AppendLine("Font Size: " + fontSize);
builder.AppendLine("Font Height: " + FontHeight);
builder.AppendLine("Font Style: " + style.ToString());
builder.AppendLine("Bold: " + font.Bold.ToString());
builder.AppendLine("Italic: " + font.Italic.ToString());
builder.AppendLine("Underline: " + font.Underline.ToString());
builder.AppendLine("Strikeout: " + font.Strikeout.ToString());
//Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty);
//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)
'Get font Name.
Dim fontName As String = font.Name
'Get font size.
Dim fontSize As Single = font.Size
'Get font height.
Dim fontHeight As Single = font.Height
'Get the font style.
Dim style As PdfFontStyle = font.Style
Dim builder As New StringBuilder()
builder.AppendLine("Font Name: " + fontName)
builder.AppendLine("Font Size: " + fontSize)
builder.AppendLine("Font Height: " + fontHeight)
builder.AppendLine("Font Style: " + style.ToString())
builder.AppendLine("Bold: " + font.Bold.ToString())
builder.AppendLine("Italic: " + font.Italic.ToString())
builder.AppendLine("Underline: " + font.Underline.ToString())
builder.AppendLine("Strikeout: " + font.Strikeout.ToString())
'Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Height
Gets the height of the font in points.
public float Height { get; }
Property Value
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);
//Get font Name.
string fontName = font.Name;
//Get font size.
float fontSize = font.Size;
//Get font height.
float fontHeight = font.Height;
//Get the font style.
PdfFontStyle style = font.Style;
StringBuilder builder = new StringBuilder();
builder.AppendLine("Font Name: " + fontName);
builder.AppendLine("Font Size: " + fontSize);
builder.AppendLine("Font Height: " + FontHeight);
builder.AppendLine("Font Style: " + style.ToString());
//Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty);
//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)
'Get font Name.
Dim fontName As String = font.Name
'Get font size.
Dim fontSize As Single = font.Size
'Get font height.
Dim fontHeight As Single = font.Height
'Get the font style.
Dim style As PdfFontStyle = font.Style
Dim builder As New StringBuilder()
builder.AppendLine("Font Name: " + fontName)
builder.AppendLine("Font Size: " + fontSize)
builder.AppendLine("Font Height: " + fontHeight)
builder.AppendLine("Font Style: " + style.ToString())
'Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Italic
Gets a value indicating whether this PdfFont has the italic style applied.
public bool Italic { get; }
Property Value
- bool
true
if italic; otherwise,false
.
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);
//Get font Name.
string fontName = font.Name;
//Get font size.
float fontSize = font.Size;
//Get font height.
float fontHeight = font.Height;
//Get the font style.
PdfFontStyle style = font.Style;
StringBuilder builder = new StringBuilder();
builder.AppendLine("Font Name: " + fontName);
builder.AppendLine("Font Size: " + fontSize);
builder.AppendLine("Font Height: " + FontHeight);
builder.AppendLine("Font Style: " + style.ToString());
builder.AppendLine("Bold: " + font.Bold.ToString());
builder.AppendLine("Italic: " + font.Italic.ToString());
builder.AppendLine("Underline: " + font.Underline.ToString());
builder.AppendLine("Strikeout: " + font.Strikeout.ToString());
//Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty);
//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)
'Get font Name.
Dim fontName As String = font.Name
'Get font size.
Dim fontSize As Single = font.Size
'Get font height.
Dim fontHeight As Single = font.Height
'Get the font style.
Dim style As PdfFontStyle = font.Style
Dim builder As New StringBuilder()
builder.AppendLine("Font Name: " + fontName)
builder.AppendLine("Font Size: " + fontSize)
builder.AppendLine("Font Height: " + fontHeight)
builder.AppendLine("Font Style: " + style.ToString())
builder.AppendLine("Bold: " + font.Bold.ToString())
builder.AppendLine("Italic: " + font.Italic.ToString())
builder.AppendLine("Underline: " + font.Underline.ToString())
builder.AppendLine("Strikeout: " + font.Strikeout.ToString())
'Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Name
Gets the face name of this Font.
public string Name { get; }
Property Value
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);
//Get font Name.
string fontName = font.Name;
//Get font size.
float fontSize = font.Size;
//Get font height.
float fontHeight = font.Height;
//Get the font style.
PdfFontStyle style = font.Style;
StringBuilder builder = new StringBuilder();
builder.AppendLine("Font Name: " + fontName);
builder.AppendLine("Font Size: " + fontSize);
builder.AppendLine("Font Height: " + FontHeight);
builder.AppendLine("Font Style: " + style.ToString());
//Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty);
//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)
'Get font Name.
Dim fontName As String = font.Name
'Get font size.
Dim fontSize As Single = font.Size
'Get font height.
Dim fontHeight As Single = font.Height
'Get the font style.
Dim style As PdfFontStyle = font.Style
Dim builder As New StringBuilder()
builder.AppendLine("Font Name: " + fontName)
builder.AppendLine("Font Size: " + fontSize)
builder.AppendLine("Font Height: " + fontHeight)
builder.AppendLine("Font Style: " + style.ToString())
'Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Size
Gets the size of this font.
public float Size { get; }
Property Value
- float
The em-size of this Font.
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);
//Get font Name.
string fontName = font.Name;
//Get font size.
float fontSize = font.Size;
//Get font height.
float fontHeight = font.Height;
//Get the font style.
PdfFontStyle style = font.Style;
StringBuilder builder = new StringBuilder();
builder.AppendLine("Font Name: " + fontName);
builder.AppendLine("Font Size: " + fontSize);
builder.AppendLine("Font Height: " + FontHeight);
builder.AppendLine("Font Style: " + style.ToString());
//Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty);
//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)
'Get font Name.
Dim fontName As String = font.Name
'Get font size.
Dim fontSize As Single = font.Size
'Get font height.
Dim fontHeight As Single = font.Height
'Get the font style.
Dim style As PdfFontStyle = font.Style
Dim builder As New StringBuilder()
builder.AppendLine("Font Name: " + fontName)
builder.AppendLine("Font Size: " + fontSize)
builder.AppendLine("Font Height: " + fontHeight)
builder.AppendLine("Font Style: " + style.ToString())
'Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Strikeout
Gets a value indicating whether this PdfFont is strikeout.
public bool Strikeout { get; }
Property Value
- bool
true
if strikeout; otherwise,false
.
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);
//Get font Name.
string fontName = font.Name;
//Get font size.
float fontSize = font.Size;
//Get font height.
float fontHeight = font.Height;
//Get the font style.
PdfFontStyle style = font.Style;
StringBuilder builder = new StringBuilder();
builder.AppendLine("Font Name: " + fontName);
builder.AppendLine("Font Size: " + fontSize);
builder.AppendLine("Font Height: " + FontHeight);
builder.AppendLine("Font Style: " + style.ToString());
builder.AppendLine("Bold: " + font.Bold.ToString());
builder.AppendLine("Italic: " + font.Italic.ToString());
builder.AppendLine("Underline: " + font.Underline.ToString());
builder.AppendLine("Strikeout: " + font.Strikeout.ToString());
//Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty);
//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)
'Get font Name.
Dim fontName As String = font.Name
'Get font size.
Dim fontSize As Single = font.Size
'Get font height.
Dim fontHeight As Single = font.Height
'Get the font style.
Dim style As PdfFontStyle = font.Style
Dim builder As New StringBuilder()
builder.AppendLine("Font Name: " + fontName)
builder.AppendLine("Font Size: " + fontSize)
builder.AppendLine("Font Height: " + fontHeight)
builder.AppendLine("Font Style: " + style.ToString())
builder.AppendLine("Bold: " + font.Bold.ToString())
builder.AppendLine("Italic: " + font.Italic.ToString())
builder.AppendLine("Underline: " + font.Underline.ToString())
builder.AppendLine("Strikeout: " + font.Strikeout.ToString())
'Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Style
Gets the style information for this font.
public PdfFontStyle Style { get; }
Property Value
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);
//Get font Name.
string fontName = font.Name;
//Get font size.
float fontSize = font.Size;
//Get font height.
float fontHeight = font.Height;
//Get the font style.
PdfFontStyle style = font.Style;
StringBuilder builder = new StringBuilder();
builder.AppendLine("Font Name: " + fontName);
builder.AppendLine("Font Size: " + fontSize);
builder.AppendLine("Font Height: " + FontHeight);
builder.AppendLine("Font Style: " + style.ToString());
//Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty);
//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)
'Get font Name.
Dim fontName As String = font.Name
'Get font size.
Dim fontSize As Single = font.Size
'Get font height.
Dim fontHeight As Single = font.Height
'Get the font style.
Dim style As PdfFontStyle = font.Style
Dim builder As New StringBuilder()
builder.AppendLine("Font Name: " + fontName)
builder.AppendLine("Font Size: " + fontSize)
builder.AppendLine("Font Height: " + fontHeight)
builder.AppendLine("Font Style: " + style.ToString())
'Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Underline
Gets a value indicating whether this PdfFont is underline.
public bool Underline { get; }
Property Value
- bool
true
if underline; otherwise,false
.
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);
//Get font Name.
string fontName = font.Name;
//Get font size.
float fontSize = font.Size;
//Get font height.
float fontHeight = font.Height;
//Get the font style.
PdfFontStyle style = font.Style;
StringBuilder builder = new StringBuilder();
builder.AppendLine("Font Name: " + fontName);
builder.AppendLine("Font Size: " + fontSize);
builder.AppendLine("Font Height: " + FontHeight);
builder.AppendLine("Font Style: " + style.ToString());
builder.AppendLine("Bold: " + font.Bold.ToString());
builder.AppendLine("Italic: " + font.Italic.ToString());
builder.AppendLine("Underline: " + font.Underline.ToString());
builder.AppendLine("Strikeout: " + font.Strikeout.ToString());
//Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty);
//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)
'Get font Name.
Dim fontName As String = font.Name
'Get font size.
Dim fontSize As Single = font.Size
'Get font height.
Dim fontHeight As Single = font.Height
'Get the font style.
Dim style As PdfFontStyle = font.Style
Dim builder As New StringBuilder()
builder.AppendLine("Font Name: " + fontName)
builder.AppendLine("Font Size: " + fontSize)
builder.AppendLine("Font Height: " + fontHeight)
builder.AppendLine("Font Style: " + style.ToString())
builder.AppendLine("Bold: " + font.Bold.ToString())
builder.AppendLine("Italic: " + font.Italic.ToString())
builder.AppendLine("Underline: " + font.Underline.ToString())
builder.AppendLine("Strikeout: " + font.Strikeout.ToString())
'Draw string to PDF page.
graphics.DrawString(builder.ToString(), font, PdfBrushes.Black, PointF.Empty)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Methods
ApplyFormatSettings(string, PdfStringFormat, float)
Applies settings to the default line width.
protected float ApplyFormatSettings(string line, PdfStringFormat format, float width)
Parameters
line
stringText line.
format
PdfStringFormatString format.
width
floatDefault line width.
Returns
- float
Line width with settings applied.
EqualsToFont(PdfFont)
Checks whether fonts are equals.
protected abstract bool EqualsToFont(PdfFont font)
Parameters
font
PdfFontFont to compare.
Returns
- bool
True if fonts are equal, False otherwise.
GetCharWidth(char, PdfStringFormat)
Returns width of the char.
protected abstract float GetCharWidth(char charCode, PdfStringFormat format)
Parameters
charCode
charChar symbol.
format
PdfStringFormatString format.
Returns
- float
Width of the symbol.
GetLineWidth(string, PdfStringFormat)
Returns width of the line.
protected abstract float GetLineWidth(string line, PdfStringFormat format)
Parameters
line
stringText line.
format
PdfStringFormatString format.
Returns
- float
Width of the line.
MeasureString(string)
Measures a string by using this font.
public SizeF MeasureString(string text)
Parameters
text
stringString to measure.
Returns
- SizeF
Size of the text.
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);
string text = "Hello World!";
//Measure the text.
SizeF size = font.MeasureString(text);
//Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(PointF.Empty, size));
//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)
Dim text As String = "Hello World!"
'Measure the text.
Dim size As SizeF = font.MeasureString(text)
'Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, New RectangleF(PointF.Empty, size))
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
MeasureString(string, SizeF)
Measures a string by using this font.
public SizeF MeasureString(string text, SizeF layoutArea)
Parameters
text
stringString to measure.
layoutArea
SizeFSizeF structure that specifies the maximum layout area for the text in points.
Returns
- SizeF
Size of the text.
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);
PdfStringFormat format = new Syncfusion.Pdf.Graphics.PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Middle;
string text = "Hello World!";
//Measure the text.
SizeF size = font.MeasureString(text, new SizeF(100,100));
//Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(PointF.Empty, size), 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)
Dim format As PdfStringFormat = New Syncfusion.Pdf.Graphics.PdfStringFormat()
format.Alignment = PdfTextAlignment.Center
format.LineAlignment = PdfVerticalAlignment.Middle
Dim text As String = "Hello World!"
'Measure the text.
Dim size As SizeF = font.MeasureString(text, New SizeF(100,100))
'Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, New RectangleF(PointF.Empty, size), format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
MeasureString(string, SizeF, PdfStringFormat)
Measures a string by using this font.
public SizeF MeasureString(string text, SizeF layoutArea, PdfStringFormat format)
Parameters
text
stringString to measure.
layoutArea
SizeFSizeF structure that specifies the maximum layout area for the text in points.
format
PdfStringFormatPdfStringFormat that represents formatting information, such as line spacing, for the string.
Returns
- SizeF
Size of the text.
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);
PdfStringFormat format = new Syncfusion.Pdf.Graphics.PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Middle;
string text = "Hello World!";
//Measure the text.
SizeF size = font.MeasureString(text, new SizeF(100,100) , format);
//Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(PointF.Empty, size), 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)
Dim format As PdfStringFormat = New Syncfusion.Pdf.Graphics.PdfStringFormat()
format.Alignment = PdfTextAlignment.Center
format.LineAlignment = PdfVerticalAlignment.Middle
Dim text As String = "Hello World!"
'Measure the text.
Dim size As SizeF = font.MeasureString(text, New SizeF(100,100), format)
'Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, New RectangleF(PointF.Empty, size), format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
MeasureString(string, SizeF, PdfStringFormat, out int, out int)
Measures a string by using this font.
public SizeF MeasureString(string text, SizeF layoutArea, PdfStringFormat format, out int charactersFitted, out int linesFilled)
Parameters
text
stringString to measure.
layoutArea
SizeFSizeF structure that specifies the maximum layout area for the text in points.
format
PdfStringFormatPdfStringFormat that represents formatting information, such as line spacing, for the string.
charactersFitted
intNumber of characters in the string.
linesFilled
intNumber of text lines in the string.
Returns
- SizeF
Size of the text.
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);
PdfStringFormat format = new Syncfusion.Pdf.Graphics.PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Middle;
string text = "Hello World!";
int charactersFilled, linesFilled;
//Measure the text.
SizeF size = font.MeasureString(text, new SizeF(100, 100), format , out charactersFilled, linesFilled);
//Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(PointF.Empty, size), 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)
Dim format As PdfStringFormat = New Syncfusion.Pdf.Graphics.PdfStringFormat()
format.Alignment = PdfTextAlignment.Center
format.LineAlignment = PdfVerticalAlignment.Middle
Dim text As String = "Hello World!"
Dim charactersFilled As Integer, linesFilled As Integer
'Measure the text.
Dim size As SizeF = font.MeasureString(text, New SizeF(100,100), format, charactersFilled, linesFilled)
'Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, New RectangleF(PointF.Empty, size), format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
MeasureString(string, PdfStringFormat)
Measures a string by using this font.
public SizeF MeasureString(string text, PdfStringFormat format)
Parameters
text
stringString to measure.
format
PdfStringFormatPdfStringFormat that represents formatting information, such as line spacing, for the string.
Returns
- SizeF
Size of the text.
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);
PdfStringFormat format = new Syncfusion.Pdf.Graphics.PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Middle;
string text = "Hello World!";
//Measure the text.
SizeF size = font.MeasureString(text, format);
//Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(PointF.Empty, size), 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)
Dim format As PdfStringFormat = New Syncfusion.Pdf.Graphics.PdfStringFormat()
format.Alignment = PdfTextAlignment.Center
format.LineAlignment = PdfVerticalAlignment.Middle
Dim text As String = "Hello World!"
'Measure the text.
Dim size As SizeF = font.MeasureString(text, format)
'Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, New RectangleF(PointF.Empty, size), format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
MeasureString(string, PdfStringFormat, out int, out int)
Measures a string by using this font.
public SizeF MeasureString(string text, PdfStringFormat format, out int charactersFitted, out int linesFilled)
Parameters
text
stringString to measure.
format
PdfStringFormatPdfStringFormat that represents formatting information, such as line spacing, for the string.
charactersFitted
intNumber of characters in the string.
linesFilled
intNumber of text lines in the string.
Returns
- SizeF
Size of the text.
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);
PdfStringFormat format = new Syncfusion.Pdf.Graphics.PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Middle;
string text = "Hello World!";
int charactersFilled, linesFilled;
//Measure the text.
SizeF size = font.MeasureString(text, format , out charactersFilled, linesFilled);
//Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(PointF.Empty, size), 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)
Dim format As PdfStringFormat = New Syncfusion.Pdf.Graphics.PdfStringFormat()
format.Alignment = PdfTextAlignment.Center
format.LineAlignment = PdfVerticalAlignment.Middle
Dim text As String = "Hello World!"
Dim charactersFilled As Integer, linesFilled As Integer
'Measure the text.
Dim size As SizeF = font.MeasureString(text, format, charactersFilled, linesFilled)
'Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, New RectangleF(PointF.Empty, size), format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
MeasureString(string, float)
Measures a string by using this font.
public SizeF MeasureString(string text, float width)
Parameters
Returns
- SizeF
Size of the text.
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);
PdfStringFormat format = new Syncfusion.Pdf.Graphics.PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Middle;
string text = "Hello World!";
//Measure the text.
SizeF size = font.MeasureString(text, 100);
//Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(PointF.Empty, size), 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)
Dim format As PdfStringFormat = New Syncfusion.Pdf.Graphics.PdfStringFormat()
format.Alignment = PdfTextAlignment.Center
format.LineAlignment = PdfVerticalAlignment.Middle
Dim text As String = "Hello World!"
'Measure the text.
Dim size As SizeF = font.MeasureString(text, 100)
'Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, New RectangleF(PointF.Empty, size), format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
MeasureString(string, float, PdfStringFormat)
Measures a string by using this font.
public SizeF MeasureString(string text, float width, PdfStringFormat format)
Parameters
text
stringString to measure.
width
floatMaximum width of the string in points.
format
PdfStringFormatPdfStringFormat that represents formatting information, such as line spacing, for the string.
Returns
- SizeF
Size of the text.
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);
PdfStringFormat format = new Syncfusion.Pdf.Graphics.PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Middle;
string text = "Hello World!";
//Measure the text.
SizeF size = font.MeasureString(text, 100, format);
//Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(PointF.Empty, size), 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)
Dim format As PdfStringFormat = New Syncfusion.Pdf.Graphics.PdfStringFormat()
format.Alignment = PdfTextAlignment.Center
format.LineAlignment = PdfVerticalAlignment.Middle
Dim text As String = "Hello World!"
'Measure the text.
Dim size As SizeF = font.MeasureString(text, 100, format)
'Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, New RectangleF(PointF.Empty, size), format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
MeasureString(string, float, PdfStringFormat, out int, out int)
Measures a string by using this font.
public SizeF MeasureString(string text, float width, PdfStringFormat format, out int charactersFitted, out int linesFilled)
Parameters
text
stringString to measure.
width
floatMaximum width of the string in points.
format
PdfStringFormatPdfStringFormat that represents formatting information, such as line spacing, for the string.
charactersFitted
intNumber of characters in the string.
linesFilled
intNumber of text lines in the string.
Returns
- SizeF
Size of the text.
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);
PdfStringFormat format = new Syncfusion.Pdf.Graphics.PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Middle;
string text = "Hello World!";
int charactersFilled, linesFilled;
//Measure the text.
SizeF size = font.MeasureString(text, format, 100, out charactersFilled, linesFilled);
//Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(PointF.Empty, size), 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)
Dim format As PdfStringFormat = New Syncfusion.Pdf.Graphics.PdfStringFormat()
format.Alignment = PdfTextAlignment.Center
format.LineAlignment = PdfVerticalAlignment.Middle
Dim text As String = "Hello World!"
Dim charactersFilled As Integer, linesFilled As Integer
'Measure the text.
Dim size As SizeF = font.MeasureString(text, 100, format, charactersFilled, linesFilled)
'Draw string to PDF page.
graphics.DrawString(text, font, PdfBrushes.Black, New RectangleF(PointF.Empty, size), format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
SetStyle(PdfFontStyle)
Sets the style.
protected void SetStyle(PdfFontStyle style)
Parameters
style
PdfFontStyleThe style.