Skip to content

altchunk

altchunk

The AltChunk object, an embedded document Word imports when it opens the file.

AltChunk

AltChunk(altChunk: CT_AltChunk, parent: ProvidesStoryPart)

Bases: StoryChild

Proxy for a w:altChunk element, an "alternative format import".

An alt-chunk holds a document in a format other than WordprocessingML — HTML, RTF, plain text, MHTML, or another .docx. Word converts it and splices the result into the document at this position when it opens the file.

The conversion is Word's, and it happens on open. This library stores and returns the embedded bytes unchanged and does not read into them, so the paragraphs and tables the alt-chunk will eventually contribute do not appear in Document.paragraphs, Document.tables or Document.iter_inner_content().

Source code in src/docx/altchunk.py
def __init__(self, altChunk: CT_AltChunk, parent: t.ProvidesStoryPart):
    super().__init__(parent)
    self._element = self._altChunk = altChunk

blob property

blob: bytes

The bytes of the embedded document, exactly as they were provided.

content_type property

content_type: str

The content type of the embedded document, e.g. "text/html".