Signing archive documents in batch

GroupDocs.Signature supports signing archive files with formats like ZIP, TAR the same way as usual documents. The only difference in the SignResult of the Sign method will contain for archive files the lists of Succeeded and Failed of the Sign method will contain for archive files the lists of Succeeded signatures as the
list of the DocumentResultSignature instances.

Here are the steps to sign the archive files like ZIP, TAR with GroupDocs.Signature:

  • Create a new instance of Signature class and pass the source archive path or stream of the archive as a constructor parameter.
  • Instantiate the single SignOptions object or list of this class with the required options.
  • Call Sign method of  Signature class instance and pass SignOptions to it.
  • The passed signature options will be applied to the all documents within the archive.
  • Analyze response SignResult over the properties Succeeded and Failed signatures as the instances of the DocumentResultSignature

Sign archive document

This example shows how to sign archive document with few SignOptions.

    /**
     * <p>
     * Sign ZIP Documents with varios signature options
     * </p>
     */
Signature signature = new Signature("sample.zip");
{
    // create sign options
    TextSignOptions options = new TextSignOptions("signed!");
    {
        // set signature position
        options.setLeft(100);
        options.setTop(100);
    };
    // sign archive to new zip file
    SignResult result = signature.sign("output.zip", options);
    // analyze signed documents
     for (BaseSignature o : signResult.getSucceeded())
    {
        DocumentResultSignature document = (DocumentResultSignature)o;
        System.out.print("Document #"+ number++ +": "+document.getFileName()+". Processed: "+document.getProcessingTime()+", mls");
    }
    if (signResult.getFailed().size() > 0)
    {
        System.out.print("\nList of failed documents:");
        number = 1;
        for (BaseSignature o : signResult.getFailed())
        {
            DocumentResultSignature document = (DocumentResultSignature)o;
            System.out.print("Document #"+number++ +": "+document.getFileName()+". Processed: "+document.getProcessingTime()+", mls");
        }
    }
}

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 .NET library we provide simple, but powerful free Apps.

You are welcome to eSign PDF, Word, Excel, PowerPoint documents with free to use online GroupDocs Signature App.