Advanced search for Metadata signatures

GroupDocs.SignatureΒ provides ability to search Metadata signatures and convert obtained values to various data types.

Here are the steps to search for Metadata signature and obtain required data type with GroupDocs.Signature:

  • Create new instance ofΒ SignatureΒ class and pass source document path or stream as a constructor parameter.
  • Create objects ofΒ MetadataSearchOptionsΒ class
  • CallΒ SearchΒ method ofΒ SignatureΒ class instance and passΒ MetadataSearchOptionsΒ Β to it.
  • Call proper conversion method to obtain corresponding Metadata value to required data type.

Search for electronic Metadata signature values with various data type

This example shows how to search for Metadata signature values with various data types.

using (Signature signature = new Signature("signed.pdf"))
{
    // search for signatures in document
    List<PdfMetadataSignature> signatures = signature.Search<PdfMetadataSignature>(SignatureType.Metadata);
    // try to get each Pdf signature with proper data type added in Basic usage example SignPdfWithMetadata
    PdfMetadataSignature mdSignature;
    // See example SignPdfWithMetadata with added various data type values to signatures
    try
    {
        mdSignature = signatures.FirstOrDefault(p => p.Name == "Author");
        Console.WriteLine($"\t[{mdSignature.Name}] as String = {mdSignature.ToString()}");
        mdSignature = signatures.FirstOrDefault(p => p.Name == "CreatedOn");
        Console.WriteLine($"\t[{mdSignature.Name}] as String = {mdSignature.ToDateTime().ToShortDateString()}");
        mdSignature = signatures.FirstOrDefault(p => p.Name == "DocumentId");
        Console.WriteLine($"\t[{mdSignature.Name}] as Integer = {mdSignature.ToInteger()}");
        mdSignature = signatures.FirstOrDefault(p => p.Name == "SignatureId");
        Console.WriteLine($"\t[{mdSignature.Name}] as Double = {mdSignature.ToDouble()}");
        mdSignature = signatures.FirstOrDefault(p => p.Name == "Amount");
        Console.WriteLine($"\t[{mdSignature.Name}] as Decimal = {mdSignature.ToDecimal()}");
        mdSignature = signatures.FirstOrDefault(p => p.Name == "Total");
        Console.WriteLine($"\t[{mdSignature.Name}] as Float = {mdSignature.ToSingle()}");
    }
    catch (Exception ex)
    {
        Helper.WriteError($"Error obtaining signature: {ex.Message}");
    }
}

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 .NET 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.