PresentationPart
paper-pptx 0.2.0 API reference
Top level class in object model.
Represents the contents of the /ppt directory of a .pptx file.
Attributes
blob
attributeblobbytesbytes XML serialization of this part.
content_type
attributecontent_typestrContent-type (MIME-type) of this part.
core_properties
attributecore_propertiesCorePropertiesPartA CoreProperties object for the presentation.
Provides read/write access to the Dublin Core properties of this presentation.
notes_master
attributenotes_masterNotesMasterReturn the NotesMaster object for this presentation. If the
presentation does not have a notes master, one is created from
a default template. The same single instance is returned on each
call.
notes_master_part
attributenotes_master_partNotesMasterPartReturn the NotesMasterPart object for this presentation.
If the presentation does not have a notes master, one is created from a default template. The same single instance is returned on each call.
package
attributepackagePackagePackage this part belongs to.
part
attributepartThis 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
attributepartnamePackURIPackURI partname for this part, e.g. "/ppt/slides/slide1.xml".
presentation
attributepresentationA Presentation object providing access to the content of this
presentation.
rels
attributerels_RelationshipsCollection of relationships from this part to other parts.
Functions
add_slide
funcadd_slide(slide_layout: SlideLayout)Return (rId, slide) pair of a newly created blank slide.
New slide inherits appearance from slide_layout.
paramslide_layoutSlideLayoutdrop_rel
funcdrop_rel(rId: str) -> NoneRemove 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.
paramrIdstrReturns
Noneget_slide
funcget_slide(slide_id: int) -> Slide | NoneReturn optional related Slide object identified by slide_id.
Returns None if no slide with slide_id is related to this presentation.
paramslide_idintReturns
pptx.slide.Slide | Noneload
funcload(partname: PackURI, content_type: str, package: Package, blob: bytes)Return instance of cls loaded with parsed XML from blob.
parampartnamePackURIparamcontent_typestrparampackagePackageparamblobbytesload_rels_from_xml
funcload_rels_from_xml(xml_rels: CT_Relationships, parts: dict[PackURI, Part]) -> Noneload _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_Relationshipsparampartsdict[PackURI, Part]Returns
Nonepart_related_by
funcpart_related_by(reltype: str) -> PartReturn (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.
paramreltypestrReturns
pptx.opc.package.Partrelate_to
funcrelate_to(target: Part | str, reltype: str, is_external: bool = False) -> strReturn 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 | strparamreltypestrparamis_externalbool= FalseReturns
strrelated_part
funcrelated_part(rId: str) -> PartReturn related Part subtype identified by rId.
paramrIdstrReturns
pptx.opc.package.Partrelated_slide
funcrelated_slide(rId: str) -> SlideReturn Slide object for related SlidePart related by rId.
paramrIdstrReturns
pptx.slide.Sliderelated_slide_master
funcrelated_slide_master(rId: str) -> SlideMasterReturn SlideMaster object for SlideMasterPart related by rId.
paramrIdstrReturns
pptx.slide.SlideMasterrename_slide_parts
funcrename_slide_parts(rIds: Iterable[str])Assign incrementing partnames to the slide parts identified by rIds.
Partnames are like /ppt/slides/slide9.xml and are assigned in the order their id appears
in the rIds sequence. The name portion is always slide. The number part forms a
continuous sequence starting at 1 (e.g. 1, 2, ... 10, ...). The extension is always
.xml.
paramrIdsIterable[str]save
funcsave(path_or_stream: str | IO[bytes])Save this presentation package to path_or_stream.
path_or_stream can be either a path to a filesystem location (a string) or a
file-like object. A pass-through; :meth:pptx.opc.package.OpcPackage.save carries
the write contract.
parampath_or_streamstr | IO[bytes]slide_id
funcslide_id(slide_part)Return the slide-id associated with slide_part.
paramslide_parttarget_ref
functarget_ref(rId: str) -> strReturn URL contained in target ref of relationship identified by rId.
paramrIdstrReturns
str