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.
This example shows how to sign PDF document with several e-signatures as metadata.
Signaturesignature=newSignature("sample.pdf");// create Metadata option with predefined Metadata text
MetadataSignOptionsoptions=newMetadataSignOptions();// Create few Pdf Metadata signatures
PdfMetadataSignature[]signatures=newPdfMetadataSignature[]{newPdfMetadataSignature("Author","Mr.Scherlock Holmes"),newPdfMetadataSignature("DateCreated",newDate()),newPdfMetadataSignature("DocumentId",123456),newPdfMetadataSignature("SignatureId",123.456)//decimal value
};options.getSignatures().addRange(signatures);// sign document to file
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.
Signaturesignature=newSignature("sample.pdf");// setup options with text of signature
MetadataSignOptionsoptions=newMetadataSignOptions();// Using standard Pdf Metadata Signatures with new values
MetadataSignature[]signatures=newMetadataSignature[]{PdfMetadataSignatures.getAuthor().deepClone("Mr.Scherlock Holmes"),PdfMetadataSignatures.getCreateDate().deepClone(DateUtils.addDays(newDate(),-1)),PdfMetadataSignatures.getMetadataDate().deepClone(DateUtils.addDays(newDate(),-2)),PdfMetadataSignatures.getCreatorTool().deepClone("GD.Signature-Test"),PdfMetadataSignatures.getModifyDate().deepClone(DateUtils.addDays(newDate(),-13)),PdfMetadataSignatures.getProducer().deepClone("GroupDocs-Producer"),PdfMetadataSignatures.getEntry().deepClone("Signature"),PdfMetadataSignatures.getKeywords().deepClone("GroupDocs, Signature, Metadata, Creation Tool"),PdfMetadataSignatures.getTitle().deepClone("Metadata Example"),PdfMetadataSignatures.getSubject().deepClone("Metadata Test Example"),PdfMetadataSignatures.getDescription().deepClone("Metadata Test example description"),PdfMetadataSignatures.getCreator().deepClone("GroupDocs.Signature"),};options.getSignatures().addRange(signatures);// sign document to file
signature.sign("sample_signed.pdf",options);
More resources
Advanced Usage Topics
To learn more about document eSign features, please refer to the advanced usage section.
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
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.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.