altchunk
altchunk
¶
AltChunkPart and closely related objects.
AltChunkPart
¶
AltChunkPart(
partname: PackURI,
content_type: str,
blob: bytes | None = None,
package: Package | None = None,
)
Bases: Part
An "alternative format import" part, the target of a w:altChunk reference.
Holds an embedded document in some format other than WordprocessingML — HTML, RTF, plain text, MHTML, or another .docx — for Word to convert and splice in when it opens the file. The bytes are stored and written back unchanged; this library has no knowledge of the embedded format.
Source code in src/docx/opc/part.py
new
classmethod
¶
new(
package: OpcPackage, blob: bytes, content_type: str
) -> AltChunkPart
An AltChunkPart newly created from blob and added to package.
Source code in src/docx/parts/altchunk.py
new_from_stream
classmethod
¶
new_from_stream(
package: OpcPackage,
chunk: str | PathLike[str] | IO[bytes],
content_type: str,
) -> AltChunkPart
An AltChunkPart newly created from chunk and added to package.
chunk is either a path to a file (a string or os.PathLike) or a file-like
object open for binary read.