Extracting property values

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.Metadata 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-metadata -- dnx GroupDocs.Metadata.Mcp --yes
Folders, licensing and more →

The most common way to get a metadata property value is to inspect its type and read the underlying value accordingly. Every MetadataProperty exposes a value (a PropertyValue) whose type tells you the data type and whose raw_value returns the underlying Python value.

from groupdocs.metadata import Metadata
from groupdocs.metadata.common import MetadataPropertyType


def extract_using_type():
    with Metadata("input.docx") as metadata:
        # Fetch all metadata properties from the file
        properties = metadata.find_properties(lambda p: True)
        for prop in properties:
            # Process string and date/time properties only (as an example)
            if prop.value.type == MetadataPropertyType.STRING:
                print(f"{prop.name} (string): {prop.value.raw_value}")
            elif prop.value.type == MetadataPropertyType.DATE_TIME:
                print(f"{prop.name} (datetime): {prop.value.raw_value}")


if __name__ == "__main__":
    extract_using_type()

input.docx is the sample file used in this example. Click here to download it.

MimeType (string): application/vnd.openxmlformats-officedocument.wordprocessingml.document
Extension (string): .docx
Author (string): Emily Carter
Category (string): 
Comments (string): 
Company (string): Profitgroup
ContentStatus (string): 
CreateTime (datetime): 2016-03-22 17:08:00+00:00
Keywords (string): 
LastPrinted (datetime): 0001-01-01 00:00:00
[TRUNCATED]

Download full output

If you need to process many supported types generically, inspect prop.value.raw_value together with prop.value.type and branch accordingly. This lets you handle arrays, numbers, booleans, nested packages, and so on in a single pass.

See also

More resources

GitHub examples

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

Free online document metadata management App

You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.