Paper Office
paper-pptxAPI referenceparts.slide

SlideLayoutPart

paper-pptx 0.2.0 API reference

Slide layout part.

Corresponds to package files ppt/slideLayouts/slideLayout[1-9][0-9]*.xml.

Attributes

blob

attributeblobbytes

bytes XML serialization of this part.

content_type

attributecontent_typestr

Content-type (MIME-type) of this part.

name

attributenamestr

Internal name of this slide.

package

attributepackagePackage

Package this part belongs to.

part

attributepart

This part.

This is part of the parent protocol, "children" of the document will not know the part that contains them so must ask their parent object. That chain of delegation ends here for child objects.

partname

attributepartnamePackURI

PackURI partname for this part, e.g. "/ppt/slides/slide1.xml".

rels

attributerels_Relationships

Collection of relationships from this part to other parts.

slide_layout

attributeslide_layout

The SlideLayout object representing this part.

slide_master

attributeslide_masterSlideMaster

Slide master from which this slide layout inherits properties.

Functions

drop_rel

funcdrop_rel(rId: str) -> None

Remove relationship identified by rId if its reference count is under 2.

Relationships with a reference count of 0 are implicit relationships. Note that only XML parts can drop relationships.

paramrIdstr

Returns

None

get_image

funcget_image(rId: str) -> Image

Return an Image object containing the image related to this slide by rId.

Raises KeyError if no image is related by that id, which would generally indicate a corrupted .pptx file.

paramrIdstr

Returns

pptx.parts.image.Image

get_or_add_image_part

funcget_or_add_image_part(image_file: str | IO[bytes])

Return (image_part, rId) pair corresponding to image_file.

The returned ImagePart object contains the image in image_file and is related to this slide with the key rId. If either the image part or relationship already exists, they are reused, otherwise they are newly created.

paramimage_filestr | IO[bytes]

load

funcload(partname: PackURI, content_type: str, package: Package, blob: bytes)

Return instance of cls loaded with parsed XML from blob.

parampartnamePackURI
paramcontent_typestr
parampackagePackage
paramblobbytes

load_rels_from_xml

funcload_rels_from_xml(xml_rels: CT_Relationships, parts: dict[PackURI, Part]) -> None

load _Relationships for this part from xml_rels.

Part references are resolved using the parts dict that maps each partname to the loaded part with that partname. These relationships are loaded from a serialized package and so already have assigned rIds. This method is only used during package loading.

paramxml_relsCT_Relationships
parampartsdict[PackURI, Part]

Returns

None
funcpart_related_by(reltype: str) -> Part

Return (single) part having relationship to this package of reltype.

Raises KeyError if no such relationship is found and ValueError if more than one such relationship is found.

paramreltypestr

Returns

pptx.opc.package.Part

relate_to

funcrelate_to(target: Part | str, reltype: str, is_external: bool = False) -> str

Return rId key of relationship of reltype to target.

If such a relationship already exists, its rId is returned. Otherwise the relationship is added and its new rId returned.

paramtargetPart | str
paramreltypestr
paramis_externalbool
= False

Returns

str
funcrelated_part(rId: str) -> Part

Return related Part subtype identified by rId.

paramrIdstr

Returns

pptx.opc.package.Part

target_ref

functarget_ref(rId: str) -> str

Return URL contained in target ref of relationship identified by rId.

paramrIdstr

Returns

str

On this page