Skip to content

customprops

customprops

Custom properties part, corresponds to /docProps/custom.xml part in package.

CustomPropertiesPart

CustomPropertiesPart(
    partname: PackURI,
    content_type: str,
    element: BaseOxmlElement,
    package: Package,
)

Bases: XmlPart

Corresponds to part named /docProps/custom.xml.

Holds the arbitrary named values an application attaches to a document, as opposed to the Dublin-Core properties in /docProps/core.xml and the application properties in /docProps/app.xml.

Source code in src/docx/opc/part.py
def __init__(
    self, partname: PackURI, content_type: str, element: BaseOxmlElement, package: Package
):
    super(XmlPart, self).__init__(partname, content_type, package=package)
    self._element = element

custom_properties property

custom_properties: CustomProperties

A CustomProperties object providing read/write access to the custom properties contained in this part.

default classmethod

default(package: OpcPackage) -> CustomPropertiesPart

Return a new CustomPropertiesPart holding no properties.

Most documents have no custom properties part at all, so one is created only when the collection is first reached.

Source code in src/docx/opc/parts/customprops.py
@classmethod
def default(cls, package: OpcPackage) -> CustomPropertiesPart:
    """Return a new |CustomPropertiesPart| holding no properties.

    Most documents have no custom properties part at all, so one is created only
    when the collection is first reached.
    """
    return cls._new(package)