Drawing
paper-docx 0.2.0 API reference
Container for a DrawingML object.
Drawing(drawing: CT_Drawing, parent: t.ProvidesStoryPart)Attributes
has_picture
attributehas_pictureboolTrue when drawing contains an embedded picture.
A drawing can contain a picture, but it can also contain a chart, SmartArt, or a
drawing canvas. Methods related to a picture, like .image, will raise when the drawing
does not contain a picture. Use this value to determine whether image methods will succeed.
This value is False when a linked picture is present. This should be relatively rare and
the image would only be retrievable from the filesystem.
Note this does not distinguish between inline and floating images. The presence of either
one will cause this value to be True.
image
attributeimageImageAn Image proxy object for the image in this (picture) drawing.
Raises ValueError when this drawing does contains something other than a picture. Use
.has_picture to qualify drawing objects before using this property.
part
attributepartXmlPartThe package part containing this object.
Functions
replace_picture
funcreplace_picture(image_descriptor: str | IO[bytes]) -> NoneSwap this drawing's image bytes, keeping display size and position.
Always writes a new image part, so other shapes sharing the old part are unchanged; the old relationship stays behind. Refuses a drawing with no picture, a linked picture whose bytes live outside the package, and a protected document.
paramimage_descriptorstr | IO[bytes]Returns
None