Signing archive documents in batch

GroupDocs.SignatureΒ supports signing archive files with formats like ZIP, TAR, 7Z 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 signatures as the
list of the DocumentResultSignature instances.

Here are the steps to sign the archive files like ZIP, TAR, 7z 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.

/// <summary>
/// Support Succeeded and Failed list as result of processing archives
/// </summary>
using (var signature = new Signature("sample.zip"))
{
    // create sign options
    var options = new TextSignOptions("signed!")
    {
        // set signature position
        Left = 100,
        Top = 100
    };
    // sign archive to new zip file
    SignResult result = signature.Sign("output.zip", options);
    // analyze signed documents
    foreach (DocumentResultSignature document in result.Succeeded)
    {
        Console.WriteLine($"Document {document.FileName}. Processed: {document.ProcessingTime}, mls");
    }
    if (signResult.Failed.Count > 0)
    {
        Console.WriteLine("\nList of failed documents:");
        number = 1;
        foreach (DocumentResultSignature document in result.Failed)
        {
            Console.WriteLine($"Document {document.FileName}. Processed: {document.ProcessingTime}, mls");
        }
    }
}

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 .NET 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.