Comparing documents

The reference figure and the steps below explain the process of comparing documents in ONLYOFFICE Document Server.

Comparing documents
  1. The user opens the document for viewing or editing using the document manager (found in his/her browser).
  2. The document storage service sends the document information using the JavaScript API to the document editor and specifies the possibility to choose the file from the document manager.
  3. The file is opened for editing.
  4. The user sends a request to get a list of storage documents for comparing by clicking the Document from Storage button in the document editor.
  5. The document editor informs the document manager about the request.
  6. The document manager sends the document to the document editor for comparing.
  1. Create an html file to Open the document.
  2. Specify the event handler for the Document from Storage button to be displayed in the Compare options in the configuration script for Document Editor initialization. When the user clicks the button, the onRequestCompareFile event is called and they can select the document for comparing from the Storage.

    Comparing files
    var onRequestCompareFile = function() {
        docEditor.setRevisedFile({
            "fileType": "docx",
            "url": "https://example.com/url-to-example-document.docx"
        });
    };
    
    var docEditor = new DocsAPI.DocEditor("placeholder", {
        "events": {
            "onRequestCompareFile": onRequestCompareFile,
            ...
        },
        ...
    });           
    
  3. In order to select a document for comparing, the setRevisedFile method must be called:

    docEditor.setRevisedFile({
        "fileType": "docx",
        "url": "https://example.com/url-to-example-document.docx"
    });                     
    
  4. After that the user can accept or reject the changes using the corresponding buttons on the top toolbar.

    Accept changes