eSign PDF with Metadata signature
GroupDocs.Signature provides PdfMetadataSignature class to specify different Metadata signature objects for MetadataSignOptions instance.
PDF document metadata is hidden attributes, some of them are visible only over viewing standard document properties like Author, Creation Date, Producer, Entry, Keywords etc.
PDF document metadata contains 3 fields: Name, Value and TagPrefix, combination of Name and Tag prefix should be unique.
PDF document metadata could keep big amount of data that provides ability to keep serialized custom objects with additional encryption in there. See Advanced examples how to embed secure data.
Here are the steps to add metadata signatures into PDF document with GroupDocs.Signature:
- Create new instance of Signature class and pass source document path as a constructor parameter.
- Instantiate the MetadataSignOptions object according to your requirements.
- Instantiate one or severalPdfMetadataSignature objects and add them into MetadataSignOptions to metadata signatures collection (Signatures) via Add or AddRange method.
- Call Sign method of Signature class instance and pass MetadataSignOptions to it.
How to eSign PDF with Metadata signature
This example shows how to sign PDF document with several e-signatures as metadata.
using (Signature signature = new Signature("sample.pdf"))
{
MetadataSignOptions options = new MetadataSignOptions();
// Create few Pdf Metadata signatures with different data types
PdfMetadataSignature[] signatures = new PdfMetadataSignature[]
{
new PdfMetadataSignature("Author", "Mr.Scherlock Holmes"),
new PdfMetadataSignature("DateCreated", DateTime.Now),
new PdfMetadataSignature("DocumentId", 123456),
new PdfMetadataSignature("SignatureId", 123.456M)
};
// add these signatures to options
options.Signatures.AddRange(signatures);
signature.Sign("SampleSigned.pdf", options);
}
How to eSign PDF with standard metadata signatures
This example shows how to sign PDF document with standard standard embedded PDF document metadata signatures. If PDF metadata signature already exists with same name its value will be overwritten.
using (Signature signature = new Signature("sample.pdf"))
{
MetadataSignOptions options = new MetadataSignOptions();
// Using standard Pdf Metadata Signatures with new values
MetadataSignature[] signatures = new MetadataSignature[]
{
PdfMetadataSignatures.Author.Clone("Mr.Scherlock Holmes"),
PdfMetadataSignatures.CreateDate.Clone(DateTime.Now.AddDays(-1)),
PdfMetadataSignatures.MetadataDate.Clone(DateTime.Now.AddDays(-2)),
PdfMetadataSignatures.CreatorTool.Clone("GD.Signature-Test"),
PdfMetadataSignatures.ModifyDate.Clone(DateTime.Now.AddDays(-13)),
PdfMetadataSignatures.Producer.Clone("GroupDocs-Producer"),
PdfMetadataSignatures.Entry.Clone("Signature"),
PdfMetadataSignatures.Keywords.Clone("GroupDocs, Signature, Metadata, Creation Tool"),
PdfMetadataSignatures.Title.Clone("Metadata Example"),
PdfMetadataSignatures.Subject.Clone("Metadata Test Example"),
PdfMetadataSignatures.Description.Clone("Metadata Test example description"),
PdfMetadataSignatures.Creator.Clone("GroupDocs.Signature"),
};
options.Signatures.AddRange(signatures);
// sign document to file
signature.Sign("sample_signed.pdf", options);
}
Advanced Usage Topics
To learn more about document eSign features, please refer to the advanced usage section.
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Signature for .NET examples, plugins, and showcase
- GroupDocs.Signature for Java examples, plugins, and showcase
- Document Signature for .NET MVC UI Example
- Document Signature for .NET App WebForms UI Example
- Document Signature for Java App Dropwizard UI Example
- Document Signature for Java Spring UI Example
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.