Excluding Fonts when Rendering to HTML
When we are rendering documents into HTML, by default the fonts that are used in the document are added to HTML content. This ensures fonts availability so that you can be pretty sure that the text from the original document will appear similar in the HTML, regardless of whether the fonts are installed on the viewer's device or not. Depending on IsResourceEmbedded option of HtmlOptions class the fonts are added inline as base64-encoded fonts or as external resources.
The following document types support adding fonts into HTML:
Portable Document Format
DOC, DOCX, DOCM, DOT, DOTX, DOTM
Rich Text Format
Mobipocket e-book format
|LaTeX||TEX (since 19.1)|
Embedded fonts increase the size of the rendering result. In order to prevent adding fonts into HTML, set ExcludeFonts property of HtmlOptions class as true as shown in the code sample below:
Setting List of the Fonts to be Excluded
Adding fonts into HTML comes with the cost of the increased size of the output file. Therefore, GroupDocs.Viewer API provides a new setting - HtmlOptions.ExcludeFontsList, that allows finding the compromise, by preventing adding specific fonts (that are commonly available on most of the devices). The code sample below shows how to prevent adding fonts into output HTML. Currently, it works only for Presentation documents only. However, the support for this feature will be extended for all document types where it is applicable in the upcoming releases.
The following code sample shows how to set fonts list to be excluded.