Exclude fonts

By default, GroupDocs.Viewer embeds the fonts used in the document into HTML. This ensures correct display regardless of the required fonts existing on the viewer device. Depending on the type of HTML rendering, fonts are added as follows:

  • Embedded resources - inline 64-coded fonts
  • External resources - external files

A list of file types that support font embedding is at the end of the page.

Embedding fonts increase the size of the rendered result. To prevent adding fonts that are available on most devices to HTML, add the font names to the FontsToExclude collection of the HtmlViewOptions class.

The following code snippet shows how to prevent adding the Times New Roman font to HTML.

using (Viewer viewer = new Viewer("sample.docx"))
    // Create an HTML file.
    var viewOptions = HtmlViewOptions.ForEmbeddedResources();
    // Exclude the Times New Roman font.
    viewOptions.FontsToExclude.Add("Times New Roman");

List of format families that support adding fonts to HTML

The following source file formats support adding fonts to HTML:

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