Exclude fonts

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Viewer MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →

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 getFontsToExclude collection of the HtmlViewOptions class.

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

import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
// ...

try (Viewer viewer = new Viewer("sample.docx")) {
    HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
    viewOptions.getFontsToExclude().add("Times New Roman");
    viewer.view(viewOptions);
}

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 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