compare Method

Summary

Compares a list of LEADDocument objects.

Syntax
TypeScript
JavaScript
compare = function( 
   documentIds, 
   options, 
   userData 
) 
static compare( 
   documentIds: string[], 
   options: DocumentCompareOptions, 
   _userData?_: any 
): JQueryPromise<DocumentDifference>; 

Parameters

documentIds

The IDs of the LEADDocuments to compare.

options

The DocumentCompareOptions that the Document Comparer will use.

userData

User defined data to pass to the service.

Return Value

A Promise object that may resolve successfully to a Compare.DocumentDifference object, or fail if an error occurs.

Remarks

Exactly the ID of two LEADDocument objects must be provided to this method. The documents must be saved into the cache.

Example
TypeScript
JavaScript
const url = "https://demo.leadtools.com/images/pdf/leadtools.pdf"; 
const url2 = "https://demo.leadtools.com/images/pdf/leadtools.pdf"; 
const loadDocumentOptions = new lt.Document.LoadDocumentOptions(); 
 
lt.Document.DocumentFactory.loadFromUri(url, loadDocumentOptions) 
   .done((document1) => { 
      lt.Document.DocumentFactory.loadFromUri(url2, loadDocumentOptions) 
         .done((document2) => { 
            const options = new lt.Document.Compare.DocumentCompareOptions(); 
            lt.Document.LEADDocument.compare([document1.documentId, document2.documentId], options) 
               .done((diff) => { 
                  log("Total number of differences: " + diff.differences.length); 
                  log("Total number of insertions: " + diff.getInsertions().length); 
                  log("Total number of deletions: " + diff.getDeletions().length); 
                  diff.differences.forEach((textDiff) => { 
                     log("   Operation: " + textDiff.operation); 
                     log("   Text: " + textDiff.text); 
                     textDiff.characters.forEach((char) => { 
                        log("       Character: " + char.character); 
                        log("       Character Index: " + char.characterIndex); 
                        log("       Page Number: " + char.pageNumber); 
                        log("       Wordmap Index: " + char.wordmapIndex); 
                     }); 
                  }); 
               }) 
               .fail(showServiceError); 
         }) 
         .fail(showServiceError); 
   }) 
   .fail(showServiceError); 
class LEADDocument_CompareExample { 
    public constructor() { 
        lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/v200/LEADTOOLSEVAL.txt", "EVAL", null); 
    } 
 
    public run(buttonID: string) { 
        document.getElementById(buttonID).onclick = this.compareDocument; 
    } 
 
    compareDocument = () => { 
 
        const url = "https://demo.leadtools.com/images/pdf/leadtools.pdf"; 
        const url2 = "https://demo.leadtools.com/images/pdf/leadtools.pdf"; 
        const loadDocumentOptions = new lt.Document.LoadDocumentOptions(); 
 
        lt.Document.DocumentFactory.loadFromUri(url, loadDocumentOptions) 
            .done((document1: lt.Document.LEADDocument) => { 
                lt.Document.DocumentFactory.loadFromUri(url2, loadDocumentOptions) 
                    .done((document2: lt.Document.LEADDocument) => { 
                        const options = new lt.Document.Compare.DocumentCompareOptions(); 
                        lt.Document.LEADDocument.compare([document1.documentId, document2.documentId], options) 
                            .done((diff) => { 
                                log("Total number of differences: " + diff.differences.length); 
                                log("Total number of insertions: " + diff.getInsertions().length); 
                                log("Total number of deletions: " + diff.getDeletions().length); 
                                diff.differences.forEach((textDiff) => { 
                                    log("   Operation: " + textDiff.operation); 
                                    log("   Text: " + textDiff.text); 
                                    textDiff.characters.forEach((char) => { 
                                        log("       Character: " + char.character); 
                                        log("       Character Index: " + char.characterIndex); 
                                        log("       Page Number: " + char.pageNumber); 
                                        log("       Wordmap Index: " + char.wordmapIndex); 
                                    }); 
                                }); 
                            }) 
                            .fail(showServiceError); 
                    }) 
                    .fail(showServiceError); 
            }) 
            .fail(showServiceError); 
    } 
} 

Requirements

Target Platforms

Help Version 20.0.2019.4.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly