Click or drag to resize

PDFNetAddFontSubst Method (String, String)

AddFontSubst functions can be used to create font substitutes that can override default PDFNet font selection algorithm. These functions are useful in situations where referenced fonts are not present in the document and PDFNet font substitution algorithm is not producing desired results. AddFontSubst(fontname, fontpath) maps the given font name (i.e. 'BaseFont' entry from the font dictionary) to a font file. AddFontSubst(ordering, fontpath) maps the given character ordering (see Ordering entry in CIDSystemInfo dictionary; Section 5.6.2 in PDF Reference) to a font file. This method is less specific that the former variant of AddFontSubst, and can be used to override a range of missing fonts (or any missing font) with a predefined substitute. The following is an example of using these functions to provide user defined font substitutes:

Namespace:  pdftron
Assembly:  pdftron (in pdftron.dll) Version: 255.255.255.255
Syntax
public static bool AddFontSubst(
	string fontname,
	string fontpath
)

Parameters

fontname
Type: SystemString
The name of the font.
fontpath
Type: SystemString
The path of the font to use with the matching name.

Return Value

Type: Boolean
True if successful.
Examples
PDFNet.initialize();
PDFNet.setResourcesPath("c:/myapp/resources");
// Specify specific font mappings...
PDFNet.addFontSubst("MinionPro-Regular", "c:/myfonts/MinionPro-Regular.otf");
PDFNet.addFontSubst("Times-Roman", "c:/windows/fonts/times.ttf");
PDFNet.addFontSubst("Times-Italic", "c:/windows/fonts/timesi.ttf");

// Specify more general font mappings...
PDFNet.addFontSubst(PDFNet.e_Identity, "c:/myfonts/arialuni.ttf");  // Arial Unicode MS
PDFNet.addFontSubst(PDFNet.e_Japan1, "c:/myfonts/KozMinProVI-Regular.otf");
PDFNet.addFontSubst(PDFNet.e_Japan2, "c:/myfonts/KozMinProVI-Regular.otf");
PDFNet.addFontSubst(PDFNet.e_Korea1, "c:/myfonts/AdobeSongStd-Light.otf");
PDFNet.addFontSubst(PDFNet.e_CNS1, "c:/myfonts/AdobeMingStd-Light.otf");
PDFNet.addFontSubst(PDFNet.e_GB1, "c:/myfonts/AdobeMyungjoStd-Medium.otf");
//...
PDFDoc doc = new PDFDoc("c:/my.pdf");
//...
See Also