GroupDocs.Comparison allows you to set the changes author name in the resulting document.
The following code snippet shows how to set the changes author:
'use strict';// Import the GroupDocs Comparison Node.js SDK
constgroupdocs=require('@groupdocs/groupdocs.comparison');// Define file paths for source, target, and result documents
constsourcePath='sample-files/source.docx';consttargetPath='sample-files/target.docx';constresultPath='result.docx';// Initialize the comparer with the source document
constcomparer=newgroupdocs.Comparer(sourcePath);// Add the target document to the comparison set
comparer.add(targetPath);// Create comparison options to customize the output
constcompareOptions=newgroupdocs.CompareOptions();// Enable revision tracking and set author information
compareOptions.setShowRevisions(true);// show changes as revisions
compareOptions.setWordTrackChanges(true);// generate Word track changes
compareOptions.setRevisionAuthorName('New author');// author name for revisions
// Execute the comparison and save the result to the specified path
comparer.compare(resultPath,compareOptions);// Terminate the process with a success exit code
process.exit(0);
This example creates a Comparer instance with the source document, adds the target document, and creates a CompareOptions object. It enables revision tracking by setting both setShowRevisions(true) and setWordTrackChanges(true), then sets the author name for revisions using setRevisionAuthorName('New author'). When the comparison is performed, all changes will be marked as revisions with the specified author name in the result document.
The result 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.