Compare bookmarks in Word documents

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 bookmarks in Word documents.

The following code snippet shows how to demonstrate how to compare bookmarks:

'use strict';

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

// Define file paths for source, target and output documents
const sourcePath = 'sample-files/source.docx';
const targetPath = 'sample-files/target.docx';
const outputPath = 'result.docx';

// Initialize the comparer with the source document
const comparer = new groupdocs.Comparer(sourcePath);

// Add the target document that will be compared against the source
comparer.add(targetPath);

// Create comparison options object to customize the comparison behavior
const compareOptions = new groupdocs.CompareOptions();

// Enable comparison of bookmarks during the process
compareOptions.setCompareBookmarks(true);

// Execute the comparison and save the result to the specified output file
comparer.compare(outputPath, compareOptions);

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

This example initializes a Comparer with the source document, adds the target document, and creates a CompareOptions object. It enables bookmark comparison by setting setCompareBookmarks(true), then performs the comparison with these options. This ensures that bookmarks in both documents are compared and any differences are highlighted in the result document.

The result of compared bookmarks is as follows:

On this page