Paper Office
paper-pptxAPI referenceparts.embeddedpackage

EmbeddedPptxPart

paper-pptx 0.2.0 API reference

A PowerPoint file stored in a part.

This part-type arises when a PowerPoint presentation (.pptx file) appears as an embedded OLE-object shape.

Attributes

blob

attributeblobbytes

Contents of this package part as a sequence of bytes.

Intended to be overridden by subclasses. Default behavior is to return the blob initial loaded during Package.open() operation.

content_type

attributecontent_type
= CT.PML_PRESENTATION

package

attributepackagePackage

Package this part belongs to.

partname

attributepartnamePackURI

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

partname_template

attributepartname_template
= '/ppt/embeddings/Microsoft_PowerPoint_Presentation%d.pptx'

rels

attributerels_Relationships

Collection of relationships from this part to other parts.

Functions

factory

funcfactory(prog_id: PROG_ID | str, object_blob: bytes, package: Package)

Return a new EmbeddedPackagePart subclass instance added to package.

The subclass is determined by prog_id which corresponds to the "application" used to open the "file-type" of object_blob. The returned part contains the bytes of object_blob and has the content-type also determined by prog_id.

paramprog_idPROG_ID | str
paramobject_blobbytes
parampackagePackage

load

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

Return cls instance loaded from arguments.

This one is a straight pass-through, but subtypes may do some pre-processing, see XmlPart for an example.

parampartnamePackURI
paramcontent_typestr
parampackagePackage
paramblobbytes

Returns

typing_extensions.Self

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

new

funcnew(blob: bytes, package: Package)

Return new EmbeddedPackagePart subclass object.

The returned part object contains blob and is added to package.

paramblobbytes
parampackagePackage
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