The Export to PDF feature in SpreadJS allows users to embed both standard fonts and custom fonts. If users don't want to use the standard fonts while exporting to PDF, they can use the custom fonts.
When custom fonts are used, PDF is embedded as the subset of the font in the file. But users must embed the font file while performing the export operation.
In order to register a custom font for exporting PDF, you can use the registerFont method of the PDFFontManager class. You can also provide a custom font file for the specific font string by using the fallbackFont method of the PDFFontManager class.
This example shows how to use the registerFont method to register a custom font.
JavaScript |
Copy Code
|
---|---|
var font = { normal: fonts['SIMSUN.ttf'] }; GC.Spread.Sheets.PDF.PDFFontsManager.registerFont('SimSun', font); |
This example shows how to use the fallbackFont method to provide a custom font file for the specific font string.
JavaScript |
Copy Code
|
---|---|
GC.Spread.Sheets.Print.PDFFontsManager.fallbackFont = function (font) { var fontInfoArray = font.split(' '), fontName = fontInfoArray[fontInfoArray.length - 1]; if (fontName === 'Calibri') { return Calibri.ttf(encode with base64); } return Arial.ttf(in ArrayBuffer) } |