GroupDocs.SignatureΒ supports signing archive files with formats like ZIP, TAR, 7Z, LZ, GZIP 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, LZ, GZIP 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.
/// <summary>/// Support Succeeded and Failed list as result of processing archives/// </summary>using(varsignature=newSignature("sample.zip")){// create sign optionsvaroptions=newTextSignOptions("signed!"){// set signature positionLeft=100,Top=100};// sign archive to new zip fileSignResultresult=signature.Sign("output.zip",options);// analyze signed documentsforeach(DocumentResultSignaturedocumentinresult.Succeeded){Console.WriteLine($"Document {document.FileName}. Processed: {document.ProcessingTime}, mls");}if(signResult.Failed.Count>0){Console.WriteLine("\nList of failed documents:");number=1;foreach(DocumentResultSignaturedocumentinresult.Failed){Console.WriteLine($"Document {document.FileName}. Processed: {document.ProcessingTime}, mls");}}}
Sign single-file archive documents
LZ and GZIP formats compress individual files into single-file archives, optimizing them for storage and transmission.
Note
The name of the archive file should match the name of the file contained.
This example shows how to sign GZIP archive document with SignOptions.
using(Signaturesignature=newSignature("sample.pdf.gz")){// create sign optionsTextSignOptionsoptions=newTextSignOptions("signed!"){// set signature positionLeft=100,Top=100};// sign archive to new zip fileSignResultresult=signature.Sign("output.pdf.gz",options);// analyze signed documentsforeach(DocumentResultSignaturedocumentinresult.Succeeded){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: