HTML Viewer - Exclude fonts

When 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 type of Html rendering (with embedded or with external resources) the fonts are added inline as base64-encoded fonts or as external resources. 

The following document types support adding fonts into HTML:

Format NameExtension
Portable Document FormatPDF
Microsoft WordDOC, DOCX, DOCM, DOT, DOTX, DOTM
Microsoft OutlookMSG, EML
Apple MailEMLX
OpenDocument FormatsODT, OTT
Rich Text FormatRTF
Electronic publicationEPUB
Mobipocket e-book formatMOBI
LaTeXTEX
Microsoft PowerPointPPT, PPTX, PPS, PPSX
OpenDocument FormatsODP
Image filesSVG 

Embedding fonts increase the size of the rendered result. In order to prevent adding specific fonts (that are commonly available on most of the devices) into HTML, add excluded font name into FontsToExclude collection of HtmlViewOptions class as shown in the code sample below. 
NOTE: 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.

            using (Viewer viewer = new Viewer("sample.docx"))
            {
                HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources();
                viewOptions.FontsToExclude.Add("Times New Roman");
                viewer.View(viewOptions);
            }

More resources

Advanced Usage Topics

To learn more about document viewing features, please refer to the advanced usage section.

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured .NET library we provide simple but powerful free Apps. You are welcome to view Word, PDF, Excel, PowerPoint documents with free to use online GroupDocs Viewer App.