Paper Office
paper-pptxAPI referenceparts.presentation

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

attributeblobbytes

bytes XML serialization of this part.

content_type

attributecontent_typestr

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

core_properties

attributecore_propertiesCorePropertiesPart

A CoreProperties object for the presentation.

Provides read/write access to the Dublin Core properties of this presentation.

notes_master

attributenotes_masterNotesMaster

Return 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_partNotesMasterPart

Return 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

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".

presentation

attributepresentation

A Presentation object providing access to the content of this presentation.

rels

attributerels_Relationships

Collection 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_layoutSlideLayout

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_slide

funcget_slide(slide_id: int) -> Slide | None

Return optional related Slide object identified by slide_id.

Returns None if no slide with slide_id is related to this presentation.

paramslide_idint

Returns

pptx.slide.Slide | None

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
funcrelated_slide(rId: str) -> Slide

Return Slide object for related SlidePart related by rId.

paramrIdstr

Returns

pptx.slide.Slide
funcrelated_slide_master(rId: str) -> SlideMaster

Return SlideMaster object for SlideMasterPart related by rId.

paramrIdstr

Returns

pptx.slide.SlideMaster

rename_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_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