Class PdfStandardFont
Represents one of the 14 standard PDF fonts. It's used to create a standard PDF font to draw the text in to the PDF
Inherited Members
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public class PdfStandardFont : PdfFont, IPdfWrapper, IPdfCache
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
PdfStandardFont(PdfFontFamily, Single)
Initializes a new instance of the PdfStandardFont class with font family and it's size
Declaration
public PdfStandardFont(PdfFontFamily fontFamily, float size)
Parameters
Type | Name | Description |
---|---|---|
PdfFontFamily | fontFamily | The font family. |
System.Single | size | The size of the 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);
//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)
PdfStandardFont(PdfFontFamily, Single, PdfFontStyle)
Initializes a new instance of the PdfStandardFont class with font family, size and font style
Declaration
public PdfStandardFont(PdfFontFamily fontFamily, float size, PdfFontStyle style)
Parameters
Type | Name | Description |
---|---|---|
PdfFontFamily | fontFamily | The font family. |
System.Single | size | The size of the font. |
PdfFontStyle | style | The style of the 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, PdfFontStyle.Bold);
//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, PdfFontStyle.Bold)
'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)
PdfStandardFont(PdfStandardFont, Single)
Initializes a new instance of the PdfStandardFont class with PdfStandardFont as prototype and font size
Declaration
public PdfStandardFont(PdfStandardFont prototype, float size)
Parameters
Type | Name | Description |
---|---|---|
PdfStandardFont | prototype | The PdfStandardFont using as prototype. |
System.Single | size | The size of the 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(new PdfStandardFont(PdfFontFamily.Helvetica,12), 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(New PdfStandardFont(PdfFontFamily.Helvetica,12), 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)
PdfStandardFont(PdfStandardFont, Single, PdfFontStyle)
Initializes a new instance of the PdfStandardFont class withPdfStandardFont as prototype,font size and font style
Declaration
public PdfStandardFont(PdfStandardFont prototype, float size, PdfFontStyle style)
Parameters
Type | Name | Description |
---|---|---|
PdfStandardFont | prototype | The PdfStandardFont using as prototype.. |
System.Single | size | The size of the font. |
PdfFontStyle | style | The style of the 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(new PdfStandardFont(PdfFontFamily.Helvetica,12), 12, PdfFontStyle.Bold);
//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(New PdfStandardFont(PdfFontFamily.Helvetica,12), 12, PdfFontStyle.Bold)
'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)
Properties
FontFamily
Gets the FontFamily.
Declaration
public PdfFontFamily FontFamily { get; }
Property Value
Type | Description |
---|---|
PdfFontFamily | The PdfFontFamily |
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(font.FontFamily.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)
'Draw string to PDF page.
graphics.DrawString(font.FontFamily.ToString(), font, PdfBrushes.Black, PointF.Empty)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Methods
EqualsToFont(PdfFont)
Checks whether fonts are equals.
Declaration
protected override bool EqualsToFont(PdfFont font)
Parameters
Type | Name | Description |
---|---|---|
PdfFont | font | Font to compare. |
Returns
Type | Description |
---|---|
System.Boolean | True if fonts are equal, False otherwise. |
Overrides
Finalize()
Releases unmanaged resources and performs other cleanup operations before the PdfStandardFont is reclaimed by garbage collection.
Declaration
protected override void Finalize()
GetCharWidth(Char, PdfStringFormat)
Returns the width of the char.
Declaration
protected override float GetCharWidth(char charCode, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.Char | charCode | Char symbol. |
PdfStringFormat | format | String format. |
Returns
Type | Description |
---|---|
System.Single | Width of the symbol. |
Overrides
GetLineWidth(String, PdfStringFormat)
Returns width of the line.
Declaration
protected override float GetLineWidth(string line, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | line | Text line. |
PdfStringFormat | format | String format. |
Returns
Type | Description |
---|---|
System.Single | Width of the line. |
Overrides
SetTextEncoding(Encoding)
Sets the text encoding in PdfFont
Declaration
public void SetTextEncoding(Encoding textEncoding)
Parameters
Type | Name | Description |
---|---|---|
System.Text.Encoding | textEncoding |
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);
//Set the text encoding
font.SetTextEncoding(Encoding.GetEncoding("Windows-1250"));
//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)
'Set the text encoding
font.SetTextEncoding(Encoding.GetEncoding("Windows-1250"))
'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)