Click or drag to resize
Pdf Library for .NET

PdfFontCreateFromFile Method

Loads a TrueType (.ttf) or OpenType (.otf) font from a file path and creates a PdfFont. The font is subset-embedded into the output document — the subset only contains glyphs that are actually used, keeping file size small. This is the path to use for PDF/A and PDF/X output from scratch.

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public static PdfFont CreateFromFile(
	string fontFile,
	float size
)

Parameters

fontFile  String
Absolute or relative path to a .ttf / .otf file.
size  Single
The font size in points.

Return Value

PdfFont
A new PdfFont backed by the embedded TrueType font.
Exceptions
ExceptionCondition
PdfDocumentExceptionThrown when the file cannot be loaded as a TrueType / OpenType font.
Example
PdfFont body = PdfFont.CreateFromFile(@"C:\Windows\Fonts\arial.ttf", 11f);
See Also