eSign PDF with Metadata signature

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.

Here are the steps to add metadata signatures into PDF document with GroupDocs.Signature:

How to eSign PDF with Metadata signature

This example shows how to sign PDF document with several e-signatures as metadata.

import groupdocs.signature as signature
from groupdocs.signature.options import MetadataSignOptions
from groupdocs.signature.domain import PdfMetadataSignature
from datetime import datetime

# Initialize signature
with signature.Signature("sample.pdf") as sign:
    # Create metadata options
    options = MetadataSignOptions()
    
    # Add metadata signatures
    options.add(PdfMetadataSignature("Author", "Mr.Scherlock Holmes"))  # String value
    options.add(PdfMetadataSignature("CreatedOn", datetime.now()))      # DateTime values
    options.add(PdfMetadataSignature("DocumentId", 123456))            # Integer value
    options.add(PdfMetadataSignature("SignatureId", 123.456))          # Double value
    options.add(PdfMetadataSignature("Amount", 123.456))               # Decimal value
    options.add(PdfMetadataSignature("Total", 123.456))                # Float value
    
    # Sign document
    sign.sign("SampleSigned.pdf", options)

How to eSign PDF with standard metadata signatures

This example shows how to sign PDF document with standard embedded PDF document metadata signatures. If PDF metadata signature already exists with same name its value will be overwritten.

import groupdocs.signature as signature
from groupdocs.signature.options import MetadataSignOptions
from groupdocs.signature.domain import PdfMetadataSignature, PdfMetadataSignatures
from datetime import datetime, timedelta

# Initialize signature
with signature.Signature("sample.pdf") as sign:
    # Create metadata options
    options = MetadataSignOptions()
    
    # Using standard Pdf Metadata Signatures with new values
    signatures = [
        PdfMetadataSignatures.AUTHOR.clone("Mr.Scherlock Holmes"),
        PdfMetadataSignatures.CREATE_DATE.clone(datetime.now() - timedelta(days=1)),
        PdfMetadataSignatures.METADATA_DATE.clone(datetime.now() - timedelta(days=2)),
        PdfMetadataSignatures.CREATOR_TOOL.clone("GD.Signature-Test"),
        PdfMetadataSignatures.MODIFY_DATE.clone(datetime.now() - timedelta(days=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")
    ]
    
    # Add signatures to options
    options.signatures.extend(signatures)
    
    # Sign document
    sign.sign("sample_signed.pdf", options)

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online Apps

Along with the full-featured Python library, we provide simple but powerful free online apps.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.