id: esign-pdf-with-metadata-signature
url: signature/net/esign-pdf-with-metadata-signature
title: Electronic Signature PDF with Metadata signature
linkTitle: Electronic Signature PDF
weight: 2
description: “This article explains how to add metadata signatures to PDF document meta info layer with GroupDocs.Signature”
keywords: Pdf metadata, Pdf metadata signatures
productName: GroupDocs.Signature for .NET
toc: True
structuredData:
showOrganization: True
application: name: Pdf documents metadata changing in C# description: Update metadata of pdf document with C# language by GroupDocs.Signature for .NET APIs
productCode: signature
productPlatform: net
showVideo: True
howTo:
name: How to append new metadata to pdf document using C#
description: Learn all about signing pdf documents by metadata and C#
steps:
- name: Load file which is planned to be signed
text: Create Signature object by passing file path or stream as a constructor parameter.
- name: Set up signing options
text: Create needed PdfMetadataSignature class instances and add them to array.
- name: Sign source file and save result
text: Invoke Sign method with array of signing options and output file path or stream.
Overview
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.
How to Electronic Signature PDF with Metadata signature
This example shows how to sign PDF document with several e-signatures as metadata.
using(Signaturesignature=newSignature("sample.pdf")){MetadataSignOptionsoptions=newMetadataSignOptions();options.Add(newPdfMetadataSignature("Author","Mr.Scherlock Holmes"))// String value.Add(newPdfMetadataSignature("CreatedOn",DateTime.Now))// DateTime values.Add(newPdfMetadataSignature("DocumentId",123456))// Integer value.Add(newPdfMetadataSignature("SignatureId",123.456D))// Double value.Add(newPdfMetadataSignature("Amount",123.456M))// Decimal value.Add(newPdfMetadataSignature("Total",123.456F));// Float value// add these signatures to optionsoptions.Signatures.AddRange(signatures);signature.Sign("SampleSigned.pdf",options);}
How to Electronic Signature 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(Signaturesignature=newSignature("sample.pdf")){MetadataSignOptionsoptions=newMetadataSignOptions();// Using standard Pdf Metadata Signatures with new valuesMetadataSignature[]signatures=newMetadataSignature[]{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 filesignature.Sign("sample_signed.pdf",options);}
Advanced Usage Topics
To learn more about document Electronic Signature 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: