Advanced search archive documents

GroupDocs.Signature searches all documents of an archive in one call: compose a list of SearchOptions objects, such as BarcodeSearchOptions or QrCodeSearchOptions, and pass it to the search method. The result is a SearchResult object. Each item of its getSucceeded() list is a DocumentResultSignature for one archive document with the signatures found in it, and the getFailed() list holds the documents that could not be processed.

Here are the steps to search for the values within the archive document with GroupDocs.Signature:

  • Create new instance of Signature class and pass source document path as a constructor parameter.
  • Instantiate the various SearchOptions objects according to your requirements. Here there’s ability to compose list of any search options types.
  • Call search method of Signature class instance and pass list of the SearchOptions to it.

This example shows how to make advanced search for any data within the archive documents.

Signature signature = new Signature("archive.zip");
try
{
    // create list of search options
    BarcodeSearchOptions bcOptions = new BarcodeSearchOptions(BarcodeTypes.Code128);
    QrCodeSearchOptions qrOptions = new QrCodeSearchOptions(QrCodeTypes.QR);

    // setup search options
    List<SearchOptions> listOptions = new ArrayList<SearchOptions>();
    listOptions.add(bcOptions);
    listOptions.add(qrOptions);

    // search archive for documents
    SearchResult searchResult = signature.search(listOptions);

    // check the result
    System.out.println("\nList of successfully processed documents:");
    int number = 1;
    for (BaseSignature item : searchResult.getSucceeded())
    {
        DocumentResultSignature document = (DocumentResultSignature) item;
        System.out.println("Document #" + number++ + ": " + document.getFileName() + ". Processed: " + document.getProcessingTime() + ", mls");
        for (BaseSignature temp : document.getSucceeded())
        {
            System.out.println("\t\t#" + temp.getSignatureId() + ": " + temp.getSignatureType());
        }
    }
    if (searchResult.getFailed().size() > 0)
    {
        System.out.println("\nList of failed documents:");
        number = 1;
        for (BaseSignature item : searchResult.getFailed())
        {
            DocumentResultSignature document = (DocumentResultSignature) item;
            System.out.println("ERROR in Document #" + number++ + "-" + document.getFileName() + ": " + document.getErrorMessage());
        }
    }
}
finally
{
    signature.dispose();
}
Note
To catch errors that the search raises as exceptions, see Searching for document signatures with exception handling.

More resources

GitHub Examples

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

Free Online Apps

Along with the full-featured Java library, we provide simple but powerful free online apps.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.