Compare multiple documents protected with password

GroupDocs.Comparison allows to compare more than 2 documents that are protected with a password.

The following are the steps to compare password-protected documents.

  • Instantiate LoadOptions object and specify source document password;
  • Instantiate Comparer objectwith source document path or stream and LoadOptions object created at previous step;
  • Instantiate another LoadOptions object and specify target document password;
  • Call add method and specify target document path or stream and LoadOptions object created at previous step. Repeat this step for every target document that is password-protected;
  • Call compare method.

The following code sample shows how to compare password-protected documents.

Compare multiple protected documents from local disk

Comparer comparer = new Comparer("C:\\source.pdf", new LoadOptions("source-password"));
try {
    comparer.add("C:\\target1.pdf", new LoadOptions("target-password"));
    comparer.add("C:\\target2.pdf", new LoadOptions("target-password"));
    comparer.add("C:\\target3.pdf", new LoadOptions("target-password"));
    comparer.compare("C:\\result.pdf");
} finally {
    comparer.dispose();
}

Compare multiple protected documents from stream

Comparer comparer = new Comparer(new FileInputStream("C:\\source.pdf"), new LoadOptions("source-password"));
try {
    comparer.add(new FileInputStream("C:\\target1.pdf"), new LoadOptions("target-password"));
    comparer.add(new FileInputStream("C:\\target2.pdf"), new LoadOptions("target-password"));
    comparer.add(new FileInputStream("C:\\target3.pdf"), new LoadOptions("target-password"));
    comparer.compare(new FileOutputStream("C:\\result.pdf"));
} finally {
    comparer.dispose();
}

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured Java library we provide simple, but powerful free Apps. You are welcome to compare your DOC or DOCX, XLS or XLSX, PPT or PPTX, PDF, EML, EMLX, MSGand other documents with free to use online GroupDocs Comparison App.