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.
This example shows how to sign archive document with few SignOptions.
/**
* <p>
* Sign ZIP Documents with varios signature options
* </p>
*/Signaturesignature=newSignature("sample.zip");{// create sign options
TextSignOptionsoptions=newTextSignOptions("signed!");{// set signature position
options.setLeft(100);options.setTop(100);};// sign archive to new zip file
SignResultresult=signature.sign("output.zip",options);// analyze signed documents
for(BaseSignatureo:signResult.getSucceeded()){DocumentResultSignaturedocument=(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(BaseSignatureo:signResult.getFailed()){DocumentResultSignaturedocument=(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: