Comparing documents
Open a document and compare it with a revised version as soon as the editor loads. The editor opens in view mode, and the comparison starts on its own, without the user clicking Compare in the editor.
The editor opens the original file and, as soon as it is ready, compares it with the revised file. The differences appear as tracked changes.
How it works
-
The editor opens the original file in view mode:
const config = {document: {fileType: "docx",key: "original-key",title: "original.docx",url: "https://example.com/original.docx",},documentType: "word",editorConfig: {mode: "view",},}; -
When the editor fires the onDocumentReady event, the setRequestedDocument method is called with the
comparetype and the URL of the revised file:config.events = {onDocumentReady() {docEditor.setRequestedDocument({c: "compare",fileType: "docx",url: "https://example.com/revised.docx",token: "<token>",});},};const docEditor = new DocsAPI.DocEditor("placeholder", config);If JWT is enabled on the document server, sign the object passed to
setRequestedDocumentwith the same secret as the editor config. See Signature for details.
To compare documents on the server without opening an editor, use the CompareDocuments method in Document Builder. The method requires a file opened with builderJS.OpenTmpFile, which is available only in Document Builder.