DocumentProperty class

DocumentProperty class

Represents a custom or built-in document property. To learn more, visit the Work with Document Properties documentation article.

Properties

NameDescription
is_link_to_contentShows whether this property is linked to content or not.
link_sourceGets the source of a linked custom document property.
nameReturns the name of the property.
typeGets the data type of the property.
valueGets or sets the value of the property.

Methods

NameDescription
to_bool()Returns the property value as bool.
to_byte_array()Returns the property value as byte array.
to_date_time()Returns the property value as DateTime in UTC.
to_double()Returns the property value as double.
to_int()Returns the property value as integer.

Examples

Shows how to work with built-in document properties.

doc = aw.Document(MY_DIR + "Properties.docx")

# The "Document" object contains some of its metadata in its members.
print(f"Document filename:\n\t \"{doc.original_file_name}\"")

# The document also stores metadata in its built-in properties.
# Each built-in property is a member of the document's "BuiltInDocumentProperties" object.
print("Built-in Properties:")
for doc_property in doc.built_in_document_properties:
    print(doc_property.name)
    print(f"\tType:\t{doc_property.type}")

    # Some properties may store multiple values.
    if isinstance(doc_property.value, list):
        for value in doc_property.value:
            print(f"\tValue:\t\"{value}\"")
    else:
        print(f"\tValue:\t\"{doc_property.value}\"")

See Also