Advanced search for Metadata signatures

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Signature MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-signature -- dnx GroupDocs.Signature.Mcp --yes
Folders, licensing and more →

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 object of MetadataSearchOptions class. Adjust its properties if needed: set Name along with NameMatchType to keep only entries with matching names, or set IncludeBuiltinProperties to true to obtain built-in document properties as well (this flag makes sense for Word Processing, Spreadsheet and Presentation documents only).
  • 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"))
{
    // set up search options: default options return all metadata signatures of the document
    MetadataSearchOptions searchOptions = new MetadataSearchOptions();
    // search for signatures in document
    List<PdfMetadataSignature> signatures = signature.Search<PdfMetadataSignature>(searchOptions);
    // 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 DateTime = {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)
    {
        Console.WriteLine($"Error obtaining signature: {ex.Message}");
    }

    // narrow the search down to metadata signatures whose names end with "Id"
    MetadataSearchOptions filteredOptions = new MetadataSearchOptions
    {
        Name = "Id",
        NameMatchType = TextMatchType.EndsWith
    };
    List<PdfMetadataSignature> filteredSignatures = signature.Search<PdfMetadataSignature>(filteredOptions);
    Console.WriteLine($"Found {filteredSignatures.Count} metadata signature(s) with name ending with 'Id'");
}
Note
Metadata search is one part of the overall document metadata workflow. See the Work with document metadata page for the complete picture: adding metadata signatures, reading built-in properties, protecting values, and known limitations.

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.