PrizmDoc v13.0 - Updated
Perform Document Comparison
Developer Guide > PrizmDoc Application Services > Perform Document Comparison

Document Comparison is a process that will compare two documents and output a document with revisions, or differences, between the two. It requires that both documents are Microsoft Office documents and that your server is a Windows server with a Microsoft Office enabled PrizmDoc license.

The following steps will walk you through the document comparison process using the PrizmDoc Application Services API. Refer to the PrizmDoc Application Services Document Comparison API section for more detailed information.

Examples in this topic:

How to create a viewingSession using Document Comparison

Issue a POST request with the body of the request containing JSON formatted ‘source’ object. The source.type property can be a “document”, “url”, or “upload”.

Example
Copy Code
POST http://localhost:3000/ViewingSession
ViewingSession POST Body
Content-Type: application/json
{
    "source": {
        "type": "comparison",
        "original": {
            "type": "document",
            "fileName": "original.docx"
        },
        "revised": {
            "type": "url",
            "url": "http://mysite.com/documents/revised.docx"
        }
    }
}
A successful response to the above POST provides the viewingSessionId in the response body:
Example
Copy Code
200 OK
Content-Type: application/json
{ "viewingSessionId": "{viewingSessionId}" }

How to add the Original Source Document that is being used for a Comparison Viewing Session to an existing, empty Viewing Session

Step 1

Issue a POST as described below to create a viewingSession with no documents specified:

Example
Copy Code
POST http://localhost:3000/ViewingSession

ViewingSession POST Body

Example
Copy Code
Content-Type: application/json
{
    "source": {
        "type": "upload",
        "displayName": "myFile.doc"
    }
}
A successful response to the above POST provides the document data in the response body:
 
Example
Copy Code
200 OK
Content-Type: application/json
{ "viewingSessionId": "{viewingSessionId}" }

Step 2

Issue a PUT as described below to upload a file to an existing viewingSession:

Example
Copy Code
PUT http://localhost:3000/v2/viewingSessions/{viewingSessionID}/sourceFile/original

ViewingSession PUT Body

Example
Copy Code
{ Binary Document Data }
A successful response to the above PUT provides a 200 OK response with no body:
Example
Copy Code
200 OK

How to Add the revised Source Document that is being used for a Comparison Viewing Session to an existing, empty Viewing Session

Step 1

Issue a POST as described below to create a viewingSession with no documents specified:

Example
Copy Code
POST http://localhost:3000/ViewingSession

ViewingSession POST Body

Example
Copy Code
Content-Type: application/json
{
    "source": {
        "type": "upload",
        "displayName": "myFile.doc"
    }
}
A successful response to the above POST provides the document data in the response body:
Example
Copy Code
200 OK
Content-Type: application/json
{ "viewingSessionId": "{viewingSessionId}" }

Step 2

Issue a PUT as described below to upload a file to an existing viewingSession:

Example
Copy Code
PUT http://localhost:3000/v2/viewingSessions/{viewingSessionID}/sourceFile/revised

ViewingSession PUT Body

Example
Copy Code
{ Binary Document Data }
A successful response to the above PUT provides a 200 OK response with no body:
 
Example
Copy Code
200 OK

How to download the Original Source Document that is being used for a Comparison Viewing Session

Issue a GET as described below using the viewingSessionId obtained from the POST request to create a viewing session:

Example
Copy Code
GET http://localhost:3000/v2/viewingSessions/{viewingSessionId}/sourceFile/original?myFile
A successful response to the above GET provides the document data in the response body:
 
Example
Copy Code
200 OK
Content-Type: application/msword
Content-Disposition: attachment; filename=myFile.pdf
{ Binary Document Data }

How to download the Revised Source Document that is being used for a Comparison Viewing Session

Issue a GET as described below using the viewingSessionId obtained from the POST request to create a viewing session:

Example
Copy Code
GET http://localhost:3000/v2/viewingSessions/{viewingSessionId}/sourceFile/revised?myFile
A successful response to the above GET provides the document data in the response body:
 
Example
Copy Code
200 OK
Content-Type: application/msword
Content-Disposition: attachment; filename=myFile.pdf
{ Binary Document Data }

How to get the Revision Data from a Document Comparison Viewing Session

Step 1

Issue a POST request with the body of the request containing JSON formatted ‘source’ object. The source.type property can be a “document”, “url”, or “upload”.

Example
Copy Code
POST http://localhost:3000/ViewingSession

ViewingSession POST Body

Example
Copy Code
Content-Type: application/json
{
    "source": {
        "type": "comparison",
        "original": {
            "type": "document",
            "fileName": "original.docx"
        },
        "revised": {
            "type": "url",
            "url": "http://mysite.com/documents/revised.docx"
        }
    }
}
A successful response to the above POST provides the viewingSessionId in the response body:
Example
Copy Code
200 OK
Content-Type: application/json
{ "viewingSessionId": "{viewingSessionId}" }

Step 2

Issue a GET request using the viewingSessionId from Step One above. Each request will return up to a limit of 100 revision data items by default. The GET request will contain a continueToken if any additional data may be available after the response is returned. You can use that continueToken in the next request to continue getting data after the ones you have already seen:

Example
Copy Code
GET http://localhost:3000/v2/viewingSessions/{viewingSessionId}/revisionData
A successful response to the above GET provides any revisions found so far, as well as, possibly, the continueToken and continueAfter items:
Example
Copy Code
200 OK
Content-Type: application/json
Content-Encoding: gzip
{
  "changes": [],
  "continueToken": "{continueToken}",
  "continueAfter": 500
}

Step 3

Issue a GET request using the viewingSessionId from Step One above and with the continueToken. It is good to wait 500ms as mentioned in the GET response from the second step as well:

Example
Copy Code
GET http://localhost:3000/v2/viewingSessions/{viewingSessionId}/revisionData?continueToken={continueToken}
A successful response to the above GET provides any revisions found after the GET request in Step Two above. If there is no continueToken, then all of the data has been retrieved and returned:
 
Example
Copy Code
200 OK
Content-Type: application/json
Content-Encoding: gzip
{
  "changes": [{revisions}]
}