CustomDocumentProperties class
CustomDocumentProperties class
A collection of custom document properties. To learn more, visit the Work with Document Properties documentation article.
Remarks
Each DocumentProperty object represents a custom property of a container document.
The names of the properties are case-insensitive.
The properties in the collection are sorted alphabetically by name.
Inheritance: CustomDocumentProperties → DocumentPropertyCollection
Indexers
Name | Description |
---|---|
__getitem__(index) |
Properties
Name | Description |
---|---|
count | Gets number of items in the collection. (Inherited from DocumentPropertyCollection) |
Methods
Name | Description |
---|---|
add(name, value) | Creates a new custom document property of the PropertyType.STRING data type. |
add(name, value) | Creates a new custom document property of the PropertyType.NUMBER data type. |
add(name, value) | Creates a new custom document property of the PropertyType.DATE_TIME data type. |
add(name, value) | Creates a new custom document property of the PropertyType.BOOLEAN data type. |
add(name, value) | Creates a new custom document property of the PropertyType.DOUBLE data type. |
add_link_to_content(name, link_source) | Creates a new linked to content custom document property. |
clear() | Removes all properties from the collection. (Inherited from DocumentPropertyCollection) |
contains(name) | Returns True if a property with the specified name exists in the collection.(Inherited from DocumentPropertyCollection) |
get_by_name(name) | Returns a DocumentProperty object by the name of the property. (Inherited from DocumentPropertyCollection) |
index_of(name) | Gets the index of a property by name. (Inherited from DocumentPropertyCollection) |
remove(name) | Removes a property with the specified name from the collection. (Inherited from DocumentPropertyCollection) |
remove_at(index) | Removes a property at the specified index. (Inherited from DocumentPropertyCollection) |
Examples
Shows how to work with custom document properties.
doc = aw.Document(MY_DIR + 'Properties.docx')
# Every document contains a collection of custom properties, which, like the built-in properties, are key-value pairs.
# The document has a fixed list of built-in properties. The user creates all of the custom properties.
self.assertEqual('Value of custom document property', str(doc.custom_document_properties.get_by_name('CustomProperty')))
doc.custom_document_properties.add('CustomProperty2', 'Value of custom document property #2')
print('Custom Properties:')
for custom_document_property in doc.custom_document_properties:
print(custom_document_property.name)
print(f'\tType:\t{custom_document_property.type}')
print(f'\tValue:\t"{custom_document_property.value}"')
See Also
- module aspose.words.properties
- class DocumentPropertyCollection
- class Document
- property Document.built_in_document_properties
- property Document.custom_document_properties