PrizmDoc® v14.2 Release - Updated
PrizmDoc / Developer Guide / PrizmDoc Application Services (PAS) / Compare Documents with PAS
In This Topic
    Compare Documents with PAS
    In This Topic

    Performing Document Comparison

    You can use PrizmDoc to show an end user a comparison view of two different Microsoft Office documents (if you are hosting the backend yourself, you must be running PrizmDoc Server on a Windows machine with a Microsoft Office enabled PrizmDoc license).

    Here is how you typically set this up:

    Step 1: Create a Comparison Viewing Session

    As with normal viewing sessions, your web application begins by sending a POST /ViewingSession request to create a new viewing session. However, this time you will set the source.type to "comparison". And, instead of providing only one document, you will provide two.

    There are different ways to provide the two documents (refer to the information about document comparison in the Viewing Sessions REST API documentation for PAS). The most common and recommended way is to have your web application upload each of them in subsequent requests.

    Here is how you would create a comparison viewing session and indicate that you intend to upload both documents in subsequent requests:

    POST pas_base_url/ViewingSession
    Content-Type: application/json
    
    {
        "source": {
            "type": "comparison",
            "displayName": "Example Comparison",
            "original": {
                "type": "upload",
                "displayName": "original.docx"
            },
            "revised": {
                "type": "upload",
                "displayName": "revised.docx"
            }
        }
    }
    
    

    NOTE: See the Base URL for PAS topic for more information.

    PAS will respond immediately, giving you a new viewingSessionId:

    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "viewingSessionId": "XYZ..."
    }
    
    

    Step 2: Initialize the Viewer

    Now that you have the viewingSessionId, your web application can go ahead and render the HTML page with the viewer configured to use that viewingSessionId. The document content will load for the end user as soon as it becomes available.

    But, in order for content to be shown, you still need to upload the two documents.

    Step 3: Upload the Two Documents

    When uploading the two documents, our API uses the terms original and revised to refer to the two documents. You issue two PUT requests: one to upload the original file, and one to upload the revised file:

    PUT pas_base_url/v2/viewingSessions/XYZ.../sourceFile/original
    
    <<file 1 bytes>>
    
    

    NOTE: See the Base URL for PAS topic for more information.

    HTTP/1.1 200 OK
    
    
    PUT pas_base_url/v2/viewingSessions/XYZ.../sourceFile/revised
    
    <<file 2 bytes>>
    
    

    NOTE: See the Base URL for PAS topic for more information.

    HTTP/1.1 200 OK
    
    

    Once both documents have been uploaded, a background process will begin automatically creating a new document which is a visual comparison of the two. Once that comparison document is ready, it will internally be set as the actual, primary document of the viewing session, and the viewer running in the browser will load the first page of this automatically-created comparison document as soon as it becomes ready.

    Additional Info

    There are additional API endpoints which allow you to download the original and revised documents you initially provided, as well as an endpoint which our viewer uses to download metadata about the revisions in the document so the end user can navigate between them. Your application may be interested in using these endpoints directly. For more information, see the relevant PrizmDoc Server REST API documentation (these endpoints can be called via PAS, which proxies the requests to PrizmDoc Server):