PdfFonts Object
Overview
PdfFonts is a collection of PdfFont objects obtainable via PdfDocument's Fonts property. The PdfFonts collection can be used to obtain standard PDF fonts, as well as non-standard fonts installed on the machine. This object also makes it possible to load TrueType/OpenType fonts directly from their .TTF or .OTF files. For more information about font management, see Section 6.2 - Font Management. Implements IEnumerable.
Member List
Properties
Returns the current number of PdfFont objects in the collection. Initially, the PdfFonts collection is empty and this property returns 0.
This is the default parameterized property returning a PdfFont object specified either by a 1-based integer index, or by font name.
If Index is an integer between 1 and Count, this property returns a PdfFont with the specified index.
If Index is a string, there are two possibilities:
Scenario 1. Index is set to one of the following pre-defined font names, and CharSet is omitted or set to pdfAnsi (0):
"Times-Roman"
"Times-Bold"
"Times-Italic"
"Times-BoldItalic
"Helvetica
"Helvetica-Bold"
"Helvetica-Oblique"
"Helvetica-BoldOblique
"Courier"
"Courier-Bold"
"Courier-Oblique"
"Courier-BoldOblique"
"Symbol"
"ZapfDingbats"This property will return an instance of PdfFont representing one of the 14 standard PDF fonts. These fonts do not have to be installed on the machine where AspPDF is installed. A standard font is not embedded in the PDF document because it is guaranteed to be supported by all PDF viewer applications.
See Appendix B - Special Font Tables for the Symbol and ZapfDingbats glyphs and their respective numeric codes.
Scenario 2. Index is set to a name other than one of the pre-defined fonts, or CharSet is set to one of the following values:
pdfDefault (1)
pdfSymbol (2)
pdfShiftJISC (128)
pdfHangul (129)
pdfGB2312 (134)
pdfChineseBig5 (136)
pdfJohab (130)
pdfHebrew (177)
pdfArabic (178)
pdfGreek (161)
pdfTurkish (162)
pdfVietnamese (163)
pdfThai (222)
pdfEastEurope (238)
pdfRussian (204)
pdfMac (77)
pdfBaltic (186)This property attempts to find a font among those installed on this machine that matches the specified font name and character set. If such a font is found, a PdfFont object representing this font is returned. Otherwise, an error exception is thrown.
Methods
Loads a TrueType or OpenType font directly from a .ttf or .otf file specified by Path. The font does not have to be properly installed on the machine (i.e. appear in the Fonts control panel).
As of Version 2.9.0.1, .ttc files (TrueType collections) are supported as well. By default, the very first font in the collection is loaded. A 1-based font index can optionally be appended to the path, separated by a comma.
Usage:
PdfFont objFont = objDoc.Fonts.LoadFromFile(@"c:\windows\fonts\arial.ttf");
PdfFont objFont = objDoc.Fonts.LoadFromFile(@"c:\windows\fonts\gulim.ttc");
PdfFont objFont = objDoc.Fonts.LoadFromFile(@"c:\windows\fonts\gulim.ttc,3");
For more information about font management, see Section 6.2 - Font Management.