The following code snippet shows how to demonstrate how to compare bookmarks:
'use strict';// Import the GroupDocs Comparison Node.js SDK
constgroupdocs=require('@groupdocs/groupdocs.comparison');// Define file paths for source, target and output documents
constsourcePath='sample-files/source.docx';consttargetPath='sample-files/target.docx';constoutputPath='result.docx';// Initialize the comparer with the source document
constcomparer=newgroupdocs.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
constcompareOptions=newgroupdocs.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:
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.