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.

How this can be done in practice

  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

    1. var onRequestCompareFile = function() {
    2. docEditor.setRevisedFile({
    3. "fileType": "docx",
    4. "url": "https://example.com/url-to-example-document.docx"
    5. });
    6. };
    7. var docEditor = new DocsAPI.DocEditor("placeholder", {
    8. "events": {
    9. "onRequestCompareFile": onRequestCompareFile,
    10. ...
    11. },
    12. ...
    13. });
  3. In order to select a document for comparing, the setRevisedFile method must be called:

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

    Accept changes