Getting known property descriptors

This example demonstrates how to extract information about the known properties that can be encountered in a particular package.

  1. Load a file to examine
  2. Get the collection of property descriptors for the desired metadata package
  3. Iterate through the extracted descriptors
from groupdocs.metadata import Metadata


def getting_known_property_descriptors():
    with Metadata("input.doc") as metadata:
        root = metadata.get_root_package()
        # Not every package exposes document properties; guard for it
        document_properties = getattr(root, "document_properties", None)
        if document_properties is not None:
            # Each descriptor describes a known property the package supports
            for descriptor in document_properties.know_property_descriptors:
                print(descriptor.name)          # property name
                print(descriptor.type)          # value type
                print(descriptor.access_level)  # read-only / read-write

                # Tags attached to the property (used by the search predicates)
                for tag in descriptor.tags:
                    print(tag)

                print()


if __name__ == "__main__":
    getting_known_property_descriptors()

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

Author
1
7
PersonCreator
DocumentPropertyTypeBuiltIn

Bytes
5
7
DesignationMeasure
[TRUNCATED]

Download full output

Note
Not all possible properties are present in the know_property_descriptors collection. The library provides information on the most frequently used properties only. If there is no descriptor for some property, it is still accessible through the GroupDocs.Metadata search engine in read-only mode.

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.