Class PdfStandardFont
- Namespace
- Syncfusion.Pdf.Graphics
- Assembly
- Syncfusion.Pdf.Portable.dll
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
public class PdfStandardFont : PdfFont
- Inheritance
-
PdfStandardFont
- 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
PdfStandardFont(PdfFontFamily, float)
Initializes a new instance of the PdfStandardFont class with font family and it's size
public PdfStandardFont(PdfFontFamily fontFamily, float size)
Parameters
fontFamilyPdfFontFamilyThe font family.
sizefloatThe 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, float, PdfFontStyle)
Initializes a new instance of the PdfStandardFont class with font family, size and font style
public PdfStandardFont(PdfFontFamily fontFamily, float size, PdfFontStyle style)
Parameters
fontFamilyPdfFontFamilyThe font family.
sizefloatThe size of the font.
stylePdfFontStyleThe 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, float)
Initializes a new instance of the PdfStandardFont class with PdfStandardFont as prototype and font size
public PdfStandardFont(PdfStandardFont prototype, float size)
Parameters
prototypePdfStandardFontThe PdfStandardFont using as prototype.
sizefloatThe 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, float, PdfFontStyle)
Initializes a new instance of the PdfStandardFont class withPdfStandardFont as prototype,font size and font style
public PdfStandardFont(PdfStandardFont prototype, float size, PdfFontStyle style)
Parameters
prototypePdfStandardFontThe PdfStandardFont using as prototype..
sizefloatThe size of the font.
stylePdfFontStyleThe 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.
public PdfFontFamily FontFamily { 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);
//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.
protected override bool EqualsToFont(PdfFont font)
Parameters
fontPdfFontFont to compare.
Returns
- bool
True if fonts are equal, False otherwise.
~PdfStandardFont()
Releases unmanaged resources and performs other cleanup operations before the PdfStandardFont is reclaimed by garbage collection.
protected ~PdfStandardFont()
GetCharWidth(char, PdfStringFormat)
Returns the width of the char.
protected override float GetCharWidth(char charCode, PdfStringFormat format)
Parameters
charCodecharChar symbol.
formatPdfStringFormatString format.
Returns
- float
Width of the symbol.
GetLineWidth(string, PdfStringFormat)
Returns width of the line.
protected override float GetLineWidth(string line, PdfStringFormat format)
Parameters
linestringText line.
formatPdfStringFormatString format.
Returns
- float
Width of the line.
SetTextEncoding(Encoding)
Sets the text encoding in PdfFont
public void SetTextEncoding(Encoding textEncoding)
Parameters
textEncodingEncoding
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)