Load custom 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.Comparison 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-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

On this page

GroupDocs.Comparison allows you to compare documents that contain non-standard fonts.

The following code snippet shows how to connect custom fonts and compare documents:

'use strict';

// Import the GroupDocs Comparison Node.js SDK
const groupdocs = require('@groupdocs/groupdocs.comparison');

// Enable strict mode for safer JavaScript
// Create LoadOptions and add a custom font directory
const loadOptions = new groupdocs.LoadOptions();
loadOptions.getFontDirectories().add('sample-files/font.otf'); // Register custom font for accurate rendering

// Define the path to the source document
const sourcePath = 'sample-files/source.docx';

// Initialize the Comparer with the source file and the load options
const comparer = new groupdocs.Comparer(sourcePath, loadOptions);

// Add the target document to the comparison set
comparer.add('sample-files/target.docx');

// Perform the comparison and save the result document
comparer.compare('result.docx');

// Terminate the process with a success exit code
process.exit(0);

This example creates a LoadOptions instance and adds a custom font directory using getFontDirectories().add(). It then initializes the Comparer with the source document path and the LoadOptions object, which ensures that custom fonts are available during comparison. The target document is added, and the comparison is performed. This allows documents with non-standard fonts to be compared accurately, as the custom fonts are registered and used for rendering.

On this page