Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-.NET
public class DocumentSignature
{
// specify SkipSerialization attribute to skip this field on serialization
[SkipSerialization]
public string Version { get; set; }
// specify SkipSerialization attribute to skip this field on serialization
[SkipSerialization]
public bool IsProcessed { get; set; }
[Format("SignatureID")]
public string ID { get; set; }
[Format("Author")]
public string Author { get; set; }
[Format("SignatureDate","yyyy-MM-dd")]
public DateTime Signed { get; set; }
[Format("Factor", "N2")]
public decimal DataFactor { get; set; }
}
//For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-.NET
// Setup key and passphrase
string key = "1234567890";
string salt = "1234567890";
// Create data encryption
IDataEncryption encryption = new SymmetricEncryption(SymmetricAlgorithmType.Rijndael, key, salt);
// Setup Signature configuration
SignatureConfig signConfig = new SignatureConfig
{
StoragePath = @"c:\Aspose\Test\Storage",
OutputPath = @"c:\Aspose\Test\Output"
};
// Instantiate the signature handler
SignatureHandler handler = new SignatureHandler(signConfig);
// Setup options with text of signature
PdfMetadataSignOptions signOptions = new PdfMetadataSignOptions();
// Create custom object
DocumentSignature signature = new DocumentSignature()
{
ID = Guid.NewGuid().ToString(),
Author = Environment.UserName,
Signed = DateTime.Now,
DataFactor = 11.22M
};
// Specify different Metadata Signatures and add them to signature collection
PdfMetadataSignature mdDocument = new PdfMetadataSignature("DocumentSignature", signature);
// Set encryption
mdDocument.DataEncryption = encryption;
signOptions.MetadataSignatures.Add(mdDocument);
// Sign document
string signedPath = handler.Sign<string>("test.pdf", signOptions,
new SaveOptions { OutputType = OutputType.String, OutputFileName = "SignedMedataDataEncrypted.pdf" });
Console.WriteLine("Signed file path is: " + signedPath);
//For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-.NET
// Setup Signature configuration
SignatureConfig signConfig = new SignatureConfig
{
StoragePath = @"c:\Aspose\Storage",
OutputPath = @"c:\Aspose\Output"
};
// Instantiating the signature handler
SignatureHandler handler = new SignatureHandler(signConfig);
// Setup options with text of signature
PdfMetadataSignOptions signOptions = new PdfMetadataSignOptions();
// Create custom object
DocumentSignature signature = new DocumentSignature()
{
ID = Guid.NewGuid().ToString(),
Author = Environment.UserName,
Signed = DateTime.Now,
DataFactor = 11.22M
};
// Specify different Metadata Signatures and add them to signature collection
PdfMetadataSignature mdDocument = new PdfMetadataSignature("DocumentSignature", signature);
signOptions.MetadataSignatures.Add(mdDocument);
// Sign document
string signedPath = handler.Sign<string>("test.pdf", signOptions,
new SaveOptions { OutputType = OutputType.String, OutputFileName = "SignedMedataDataEncrypted.pdf" });
Console.WriteLine("Signed file path is: " + signedPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.