Table of Contents

Class PdfFontSettings

Namespace
Syncfusion.Pdf.Graphics.Fonts
Assembly
Syncfusion.Pdf.Portable.dll

The PdfFontSettings class provides a convenient way to manage settings for TrueType fonts.

public class PdfFontSettings
Inheritance
PdfFontSettings
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;
//Load the TrueType font from the local *.ttf file.
FileStream fontStream = new FileStream("Arial.ttf", FileMode.Open, FileAccess.Read);
// Initialize the PdfFontSettings
PdfFontSettings fontSettings = new PdfFontSettings(10, PdfFontStyle.Bold, true, true, true);
PdfFont pdfFont = new PdfTrueTypeFont(fontStream, fontSettings);
//Draw the text.
graphics.DrawString("Hello World!!!", pdfFont, PdfBrushes.Black, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = 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
'Use the fontStream installed in the machine.
Dim fontStream As FileStream = New FileStream("Arial.ttf", FileMode.Open, FileAccess.Read)
Dim fontSettings As PdfFontSettings = New PdfFontSettings(10, PdfFontStyle.Bold, true, true, true)
Dim pdfFont As PdfFont = New PdfTrueTypeFont(fontStream, fontSettings)
'Draw the text.
graphics.DrawString("Hello World!!!", pdfFont, PdfBrushes.Black, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(true)

Constructors

PdfFontSettings(float, PdfFontStyle, bool, bool, bool)

Initializes a new instance of the PdfFontSettings class with the specified font style, font size, embed and subset options.

public PdfFontSettings(float fontSize, PdfFontStyle style, bool embed, bool subset, bool useFloatingFactorForMeasure)

Parameters

fontSize float

The font size, in points, to use when rendering text with this font.

style PdfFontStyle

The style of the font

embed bool

A boolean value that specifies whether to embed the font with the PDF document.

subset bool

A boolean value that specifies whether to subset the font to only include the characters used in the document.

useFloatingFactorForMeasure bool

"A boolean value that specifies whether to use a floating-point value type to measure width and render."

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;
//Load the TrueType font from the local *.ttf file.
FileStream fontStream = new FileStream("Arial.ttf", FileMode.Open, FileAccess.Read);
// Initialize the PdfFontSettings
PdfFontSettings fontSettings = new PdfFontSettings(10, PdfFontStyle.Bold, true, true, true);
PdfFont pdfFont = new PdfTrueTypeFont(fontStream, fontSettings);
//Draw the text.
graphics.DrawString("Hello World!!!", pdfFont, PdfBrushes.Black, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = 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
'Use the fontStream installed in the machine.
Dim fontStream As FileStream = New FileStream("Arial.ttf", FileMode.Open, FileAccess.Read)
Dim fontSettings As PdfFontSettings = New PdfFontSettings(10, PdfFontStyle.Bold, true, true, true)
Dim pdfFont As PdfFont = New PdfTrueTypeFont(fontStream, fontSettings)
'Draw the text.
graphics.DrawString("Hello World!!!", pdfFont, PdfBrushes.Black, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(true)

Remarks

If the embed parameter is true, the font stream data will be embedded in the PDF document. This ensures that the font will be available for viewing and printing, even if the original font is not installed on the user's computer. If the subset parameter is true, only the characters used in the document will be included in the embedded font. This can reduce the size of the PDF document, but may also make it more difficult to edit the document in the future.