Load custom fonts

On this page

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

To connect custom fonts and compare documents, follow these steps:

  1. Instantiate the LoadOptions object. Specify a list of directories with custom fonts.
  2. Instantiate the Comparer object with the source document path or stream and the LoadOptions object created in the previous step.
  3. Call the add() method. Specify the target document path or stream.
  4. Call the Comparer method.

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

import groupdocs.comparison as gc

def load_custom_fonts(output_file_path, source_file_path, target_file_path):
    # Initialize LoadOptions and add font directory
    load_options = gc.options.LoadOptions()
    load_options.font_directories.append("./fontPath/")

    # Initialize comparer with the source document
    with gc.Comparer(source_file_path, load_options) as comparer:
        # Add the target document for comparison
        comparer.add(target_file_path, load_options)
        
        # Compare the documents and save the result
        comparer.compare(output_file_path)
    
    # Log the success message with the output file path
    print(f"\nDocuments compared successfully.\nCheck output in {output_file_path}.")

On this page