customprops
customprops
¶
Custom element classes for the custom document properties part.
Stored as /docProps/custom.xml, this is the third and last of the document-properties
parts, after the Dublin-Core properties in core.xml and the application properties in
app.xml. It holds arbitrary named values, which is what document-management systems,
contract tooling and mail-merge pipelines use to carry their own keys, and what a
DOCPROPERTY field in the document body refers to.
CT_Property
¶
Bases: BaseOxmlElement
<property> element, one custom document property.
The value is carried by a single child element from the vt: variant namespace,
whose tag names the type. Writing the wrong variant for a value produces a file Word
refuses to open, so the mapping is deliberate and narrow.
value
property
writable
¶
The Python value of this property, or None for an empty or null variant.
A variant this library does not model — a vector, array or blob — reads as the raw text of the element, so nothing in a document is silently dropped, but such a property cannot be written back through a Python value.
CT_CustomProperties
¶
Bases: BaseOxmlElement
<Properties> element, the root of the custom document properties part.
new
classmethod
¶
new() -> CT_CustomProperties
add_named_property
¶
add_named_property(name: str, value: object) -> CT_Property
Return a new <property> element for name, appended to this part.
Source code in src/docx/oxml/customprops.py
get_by_name
¶
get_by_name(name: str) -> CT_Property | None
The <property> element named name, or None if there is none.
next_pid
¶
The property id to give the next property added.
One greater than the highest in use. Gaps left by deleted properties are not
reused and existing properties are never renumbered: a pid need only be
unique, and rewriting them would churn the file for no gain.