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.
fromgroupdocs.metadataimportMetadatafromgroupdocs.metadata.commonimportMetadataPropertyTypedefextract_using_type():withMetadata("input.docx")asmetadata:# Fetch all metadata properties from the fileproperties=metadata.find_properties(lambdap:True)forpropinproperties:# Process string and date/time properties only (as an example)ifprop.value.type==MetadataPropertyType.STRING:print(f"{prop.name} (string): {prop.value.raw_value}")elifprop.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.
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.