pptx

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pptx contains Puppt-owned Open XML package reading, writing, relationships, and content-type handling for modern .pptx files.

Index

Constants

View Source
const (
	CorePropertiesRelType = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
	SlideLayoutRelType    = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"
	SlideMasterRelType    = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"
	NotesSlideRelType     = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide"
	ImageRelType          = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
	VideoRelType          = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"
	AudioRelType          = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio"
	OLEObjectRelType      = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"
)

Variables

This section is empty.

Functions

func RelationshipsPartFor

func RelationshipsPartFor(partName string) string

RelationshipsPartFor returns the package relationships item name for a part.

func ResolveTargetPart

func ResolveTargetPart(sourcePart string, target string) string

ResolveTargetPart resolves an internal relationship target relative to its source part.

func Write

func Write(ctx context.Context, pkg *Package, outputPath string) error

Write writes the package parts to a .pptx ZIP archive. It preserves part bytes supplied in Package.Parts and only changes ZIP container metadata.

Types

type ContentTypes

type ContentTypes struct {
	Defaults  map[string]string
	Overrides map[string]string
}

ContentTypes contains parsed package content-type declarations.

func (ContentTypes) ForPart

func (c ContentTypes) ForPart(partName string) string

ForPart returns the best known content type for a package part.

type ErrorKind

type ErrorKind string

ErrorKind classifies package-reader failures for CLI/API reporting.

const (
	ErrorUnsupportedFileType ErrorKind = "unsupported_file_type"
	ErrorInvalidPackage      ErrorKind = "invalid_package"
	ErrorMissingPart         ErrorKind = "missing_part"
	ErrorInvalidXML          ErrorKind = "invalid_xml"
	ErrorMissingRelationship ErrorKind = "missing_relationship"
)

type Package

type Package struct {
	Path                      string
	Parts                     map[string][]byte
	ContentTypes              ContentTypes
	RootRelationships         []Relationship
	PresentationPath          string
	PresentationRelationships []Relationship
	SlideParts                []string
}

Package is the initial structural view of a .pptx package.

func FromParts added in v0.3.0

func FromParts(ctx context.Context, parts map[string][]byte, filePath string) (*Package, error)

FromParts validates package relationships and exposes the canonical slide order.

func Open

func Open(ctx context.Context, filePath string) (*Package, error)

Open reads enough of a .pptx package to validate core structure and expose presentation slide order. It does not mutate or normalize the package.

func OpenForSlide

func OpenForSlide(ctx context.Context, filePath string, slideNumber int) (*Package, error)

OpenForSlide reads the package structure and the parts reachable from one slide's render inheritance chain. It preserves slide order metadata but avoids inflating unrelated slide media.

func OpenReader added in v0.3.0

func OpenReader(ctx context.Context, input io.Reader) (*Package, error)

OpenReader reads a bounded, in-memory PPTX package without a temporary file.

func (*Package) PartNames

func (p *Package) PartNames() []string

PartNames returns package part names in deterministic order.

func (*Package) RelationshipsForPart

func (p *Package) RelationshipsForPart(partName string) ([]Relationship, error)

RelationshipsForPart returns explicit relationships for a package part. A part without a relationships item returns an empty slice.

type PackageError

type PackageError struct {
	Kind ErrorKind
	Op   string
	Path string
	Part string
	Err  error
}

PackageError is an explicit, actionable error from .pptx package handling.

func (*PackageError) Error

func (e *PackageError) Error() string

func (*PackageError) Unwrap

func (e *PackageError) Unwrap() error

type Relationship

type Relationship struct {
	ID         string
	Type       string
	Target     string
	TargetMode string
}

Relationship is an Open Packaging Convention relationship.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL