Documentation
¶
Overview ¶
Package pptx assembles PresentationML content on top of opc.Package and drawingml's shared primitives: presentation.xml, slide masters, slide layouts, slides, and the theme.
This file implements text substitution over an opened slide's raw XML — the one place Template/OpenSlide (open.go) actually mutate content. It never parses a slide into the write-only content-model structs (xml.go); it byte-splices the original bytes instead, so everything the substitution engine doesn't touch — geometry, fills, unrelated paragraphs, whole other parts — passes through exactly as loaded.
Index ¶
- Constants
- func Emu(n int) int
- func Inches(f float64) int
- func IsValidArrowheadType(t ArrowheadType) bool
- func IsValidDashStyle(style DashStyle) bool
- func IsValidLineCapStyle(style LineCapStyle) bool
- func IsValidPresetGeometry(prst PresetGeometry) bool
- func NotesSlidePath(n int) string
- func Points(f float64) int
- func RGB(r, g, b uint8) drawingml.Color
- func SlideLayoutPath(n int) string
- func SlidePath(n int) string
- type Alignment
- type ArrowheadType
- type AutofitMode
- type Bg
- type BgPr
- type BlipFill
- type CNvCxnSpPr
- type CNvGraphicFramePr
- type CNvPicPr
- type CNvPr
- type CNvSpPr
- type CSld
- type ChartBuilder
- func (cb *ChartBuilder) AddSeries(name string, categories []string, values []float64) *SeriesBuilder
- func (cb *ChartBuilder) AxisTitles(catTitle, valTitle string) *ChartBuilder
- func (cb *ChartBuilder) HasLegend(pos string) *ChartBuilder
- func (cb *ChartBuilder) SetBarDirection(dir string) *ChartBuilder
- func (cb *ChartBuilder) SetGrouping(grouping string) *ChartBuilder
- func (cb *ChartBuilder) SetHoleSize(size uint) *ChartBuilder
- func (cb *ChartBuilder) Title(title string) *ChartBuilder
- type ChartGraphic
- type ChartType
- type ClrMap
- type ClrMapOvr
- type ConnSite
- type Connector
- type ConnectorRef
- func (cr *ConnectorRef) ArrowEnd(t ArrowheadType) *ConnectorRef
- func (cr *ConnectorRef) ArrowStart(t ArrowheadType) *ConnectorRef
- func (cr *ConnectorRef) Border(c drawingml.Color, widthPoints float64) *ConnectorRef
- func (cr *ConnectorRef) BorderDash(style DashStyle) *ConnectorRef
- func (cr *ConnectorRef) BorderScheme(scheme SchemeColor, widthPoints float64) *ConnectorRef
- func (cr *ConnectorRef) LineCap(style LineCapStyle) *ConnectorRef
- func (cr *ConnectorRef) LineJoin(style LineJoinStyle) *ConnectorRef
- type ConnectorType
- type DashStyle
- type DefRPr
- type GradientStop
- type GraphicFrame
- type GraphicFrameXfrm
- type Group
- type GroupShape
- type GrpSpPr
- type LayoutType
- type LineCapStyle
- type LineJoinStyle
- type LvlPPr
- type MergeData
- type MergeOption
- type Metadata
- type NotesMasterId
- type NotesMasterIdLst
- type NotesSz
- type NumberingScheme
- type NvCxnSpPr
- type NvGraphicFramePr
- type NvGrpSpPr
- type NvPicPr
- type NvPr
- type NvSpPr
- type OpenSlide
- type Option
- func WithAuthor(author string) Option
- func WithCompany(company string) Option
- func WithDescription(description string) Option
- func WithKeywords(keywords string) Option
- func WithMetadata(m Metadata) Option
- func WithSlideSize(widthEMU, heightEMU int) Option
- func WithStandard4x3() Option
- func WithSubject(subject string) Option
- func WithTheme(t Theme) Option
- func WithTitle(title string) Option
- type Paragraph
- func (pg *Paragraph) Alignment(a Alignment) *Paragraph
- func (pg *Paragraph) Bold() *Paragraph
- func (pg *Paragraph) Bullet(char, font string) *Paragraph
- func (pg *Paragraph) Color(c drawingml.Color) *Paragraph
- func (pg *Paragraph) ColorScheme(scheme SchemeColor) *Paragraph
- func (pg *Paragraph) Font(name string) *Paragraph
- func (pg *Paragraph) FontSize(points float64) *Paragraph
- func (pg *Paragraph) Hyperlink(url string) *Paragraph
- func (pg *Paragraph) Indent(marginLeft, firstLine float64) *Paragraph
- func (pg *Paragraph) Italic() *Paragraph
- func (pg *Paragraph) Lang(tag string) *Paragraph
- func (pg *Paragraph) Level(lvl int) *Paragraph
- func (pg *Paragraph) LineSpacing(percent float64) *Paragraph
- func (pg *Paragraph) NoBullet() *Paragraph
- func (pg *Paragraph) NumberedBullet(scheme NumberingScheme) *Paragraph
- func (pg *Paragraph) NumberedBulletFrom(scheme NumberingScheme, startAt int) *Paragraph
- func (pg *Paragraph) SpaceAfter(points float64) *Paragraph
- func (pg *Paragraph) SpaceBefore(points float64) *Paragraph
- func (pg *Paragraph) Text(s string) *Paragraph
- func (pg *Paragraph) Underline() *Paragraph
- type Ph
- type Picture
- type PictureRef
- func (p *PictureRef) Border(c drawingml.Color, widthPoints float64) *PictureRef
- func (p *PictureRef) Glow(c drawingml.Color, radiusPoints float64) *PictureRef
- func (p *PictureRef) Reflection(startOpacityPercent float64) *PictureRef
- func (p *PictureRef) Shadow(c drawingml.Color, alphaPercent float64) *PictureRef
- func (p *PictureRef) SoftEdges(radiusPoints float64) *PictureRef
- type PlaceholderType
- type Presentation
- type PresetGeometry
- type SchemeColor
- type SeriesBuilder
- type Shape
- type ShapeRef
- func (sr *ShapeRef) AddParagraph() *Paragraph
- func (sr *ShapeRef) Adjust(name string, value int) *ShapeRef
- func (sr *ShapeRef) Anchor(a VerticalAnchor) *ShapeRef
- func (sr *ShapeRef) ArrowEnd(t ArrowheadType) *ShapeRef
- func (sr *ShapeRef) ArrowStart(t ArrowheadType) *ShapeRef
- func (sr *ShapeRef) Autofit(mode AutofitMode) *ShapeRef
- func (sr *ShapeRef) Border(c drawingml.Color, widthPoints float64) *ShapeRef
- func (sr *ShapeRef) BorderDash(style DashStyle) *ShapeRef
- func (sr *ShapeRef) BorderScheme(scheme SchemeColor, widthPoints float64) *ShapeRef
- func (sr *ShapeRef) Fill(c drawingml.Color) *ShapeRef
- func (sr *ShapeRef) FillScheme(scheme SchemeColor) *ShapeRef
- func (sr *ShapeRef) FlipH() *ShapeRef
- func (sr *ShapeRef) FlipV() *ShapeRef
- func (sr *ShapeRef) Glow(c drawingml.Color, radiusPoints float64) *ShapeRef
- func (sr *ShapeRef) GradientFill(angleDegrees float64, stops ...GradientStop) *ShapeRef
- func (sr *ShapeRef) Insets(left, top, right, bottom float64) *ShapeRef
- func (sr *ShapeRef) LineCap(style LineCapStyle) *ShapeRef
- func (sr *ShapeRef) LineJoin(style LineJoinStyle) *ShapeRef
- func (sr *ShapeRef) NoFill() *ShapeRef
- func (sr *ShapeRef) Reflection(startOpacityPercent float64) *ShapeRef
- func (sr *ShapeRef) Rotation(degrees float64) *ShapeRef
- func (sr *ShapeRef) Shadow(c drawingml.Color, alphaPercent float64) *ShapeRef
- func (sr *ShapeRef) SoftEdges(radiusPoints float64) *ShapeRef
- func (sr *ShapeRef) WordWrap(enabled bool) *ShapeRef
- type SldId
- type SldIdLst
- type SldLayoutId
- type SldLayoutIdLst
- type SldMasterId
- type SldMasterIdLst
- type SldSz
- type Slide
- func (s *Slide) AddChart(chartType ChartType, x, y, w, h int) *ChartBuilder
- func (s *Slide) AddGroup(x, y, w, h int) *Group
- func (s *Slide) AddImage(path string, x, y int) *PictureRef
- func (s *Slide) AddImageFromBytes(data []byte, x, y int) *PictureRef
- func (s *Slide) AddImageFromBytesWithSize(data []byte, x, y, w, h int) *PictureRef
- func (s *Slide) AddImageWithSize(path string, x, y, w, h int) *PictureRef
- func (s *Slide) AddPlaceholder(phType PlaceholderType, idx uint32) *ShapeRef
- func (s *Slide) AddShape(prst PresetGeometry, x, y, w, h int) *ShapeRef
- func (s *Slide) AddTable(rows, cols, x, y, w, h int) *Table
- func (s *Slide) AddTextBox(x, y, w, h int) *TextBox
- func (s *Slide) Background(c drawingml.Color) *Slide
- func (s *Slide) BackgroundGradient(angleDegrees float64, stops ...GradientStop) *Slide
- func (s *Slide) BackgroundScheme(scheme SchemeColor) *Slide
- func (s *Slide) Body(text string) *Paragraph
- func (s *Slide) Connect(from *ShapeRef, fromSite ConnSite, to *ShapeRef, toSite ConnSite, ...) *ConnectorRef
- func (s *Slide) DateText(text string) *Slide
- func (s *Slide) Footer(text string) *Slide
- func (s *Slide) Notes(text string) *Slide
- func (s *Slide) SlideNumber() *Slide
- func (s *Slide) Title(text string) *Paragraph
- type SlideOption
- type SpPr
- type SpTree
- type Table
- type TableCell
- func (c *TableCell) AddParagraph() *Paragraph
- func (c *TableCell) Anchor(a VerticalAnchor) *TableCell
- func (c *TableCell) Border(side TableCellSide, color drawingml.Color, widthPoints float64) *TableCell
- func (c *TableCell) BorderScheme(side TableCellSide, scheme SchemeColor, widthPoints float64) *TableCell
- func (c *TableCell) Fill(color drawingml.Color) *TableCell
- func (c *TableCell) FillScheme(scheme SchemeColor) *TableCell
- func (c *TableCell) NoFill() *TableCell
- func (c *TableCell) Text(s string) *Paragraph
- type TableCellSide
- type Template
- func (t *Template) Merge(data MergeData, opts ...MergeOption) (int, error)
- func (t *Template) PlaceholderNames(opts ...MergeOption) ([]string, error)
- func (t *Template) Replace(old, new string) (int, error)
- func (t *Template) Save(w io.Writer) error
- func (t *Template) Slide(n int) (*OpenSlide, error)
- func (t *Template) SlideCount() int
- func (t *Template) Slides() []*OpenSlide
- type TextBox
- type TextStyle
- type Theme
- type ThemeColors
- type ThemeFonts
- type TxStyles
- type VerticalAnchor
- type XMLAppProperties
- type XMLCoreProperties
- type XMLNotesMaster
- type XMLNotesSlide
- type XMLPresentation
- type XMLSlide
- type XMLSlideLayout
- type XMLSlideMaster
Constants ¶
const ( PathPresentation = "ppt/presentation.xml" PathTheme1 = "ppt/theme/theme1.xml" // PathTheme2 is the notes master's own theme part, created lazily with the // notes master (Office emits a distinct theme per master; see Slide.Notes). PathTheme2 = "ppt/theme/theme2.xml" PathSlideMaster1 = "ppt/slideMasters/slideMaster1.xml" PathCoreProps = "docProps/core.xml" PathAppProps = "docProps/app.xml" // PathSlideLayout1 is SlideLayoutPath(1) — the always-present LayoutBlank // part — spelled as a constant for callers that want the blank layout's // path without computing it. PathSlideLayout1 = "ppt/slideLayouts/slideLayout1.xml" // PathNotesMaster1 is the single notes master, created lazily the first // time any slide gets speaker notes (see Slide.Notes). PathNotesMaster1 = "ppt/notesMasters/notesMaster1.xml" )
Part paths, relative to the package root.
const ( ContentTypePresentation = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" ContentTypeSlideMaster = "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml" ContentTypeSlideLayout = "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" ContentTypeSlide = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml" ContentTypeNotesMaster = "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml" ContentTypeNotesSlide = "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml" )
Content types specific to PresentationML.
const ( RelTypeOfficeDocument = opc.NamespaceOfficeDocumentRels + "/officeDocument" RelTypeSlideMaster = opc.NamespaceOfficeDocumentRels + "/slideMaster" RelTypeSlideLayout = opc.NamespaceOfficeDocumentRels + "/slideLayout" RelTypeSlide = opc.NamespaceOfficeDocumentRels + "/slide" RelTypeNotesMaster = opc.NamespaceOfficeDocumentRels + "/notesMaster" RelTypeNotesSlide = opc.NamespaceOfficeDocumentRels + "/notesSlide" )
Relationship types specific to PresentationML (image/theme/hyperlink and the OPC-level metadata rel types are shared and live in opc.RelType*).
const ( SlideSizeWidescreen16x9Width = slideWidthEMU // 13.333in x 7.5in — PowerPoint's modern default (New's own default) SlideSizeWidescreen16x9Height = slideHeightEMU SlideSizeStandard4x3Width = 9144000 // 10in x 7.5in — the pre-2013 PowerPoint default SlideSizeStandard4x3Height = 6858000 )
Standard slide sizes, in EMUs, for use with WithSlideSize.
const NamespaceMain = "http://schemas.openxmlformats.org/presentationml/2006/main"
NamespaceMain is the PresentationML main namespace ("p:").
Variables ¶
This section is empty.
Functions ¶
func Emu ¶
Emu returns n unchanged. It exists purely so a call site can spell out "this value is already in EMUs" instead of passing a bare int.
func Inches ¶
Inches converts f inches to EMUs. Shape positions and sizes (AddTextBox and friends) are all in EMUs; this and Points exist so call sites can name their unit instead of hand-computing the conversion.
func IsValidArrowheadType ¶
func IsValidArrowheadType(t ArrowheadType) bool
IsValidArrowheadType reports whether t is one of ST_LineEndType's 6 defined values.
func IsValidDashStyle ¶
IsValidDashStyle reports whether style is one of ST_PresetLineDashVal's 11 defined preset dash pattern names.
func IsValidLineCapStyle ¶
func IsValidLineCapStyle(style LineCapStyle) bool
IsValidLineCapStyle reports whether style is one of ST_LineCap's 3 defined values.
func IsValidPresetGeometry ¶
func IsValidPresetGeometry(prst PresetGeometry) bool
IsValidPresetGeometry reports whether prst is one of ST_ShapeType's 187 defined preset geometry names.
func NotesSlidePath ¶
NotesSlidePath returns the part path for the notes slide annotating the nth slide (1-indexed) — one notes slide per annotated slide, sharing its number.
func SlideLayoutPath ¶
SlideLayoutPath returns the part path for the nth slide layout (1-indexed) — see newStandardLayouts for what each index holds.
Types ¶
type Alignment ¶
type Alignment string
Alignment is a paragraph's horizontal text alignment (a:pPr's algn attribute).
type ArrowheadType ¶
type ArrowheadType string
ArrowheadType names an arrowhead (or other line-end decoration) for use with ShapeRef.ArrowStart/ArrowEnd (a:headEnd/a:tailEnd's type attribute, ST_LineEndType). Only has visible effect on an open shape's outline (e.g. ShapeLine) — a closed autoshape's path has no defined start/end.
const ( ArrowheadNone ArrowheadType = "none" ArrowheadTriangle ArrowheadType = "triangle" ArrowheadStealth ArrowheadType = "stealth" ArrowheadDiamond ArrowheadType = "diamond" ArrowheadOval ArrowheadType = "oval" ArrowheadArrow ArrowheadType = "arrow" )
The complete ST_LineEndType enumeration.
type AutofitMode ¶
type AutofitMode string
AutofitMode controls how a shape's text behaves when it overflows the shape's bounds, for use with ShapeRef.Autofit.
const ( AutofitNone AutofitMode = "none" // text may overflow the shape uncorrected AutofitShrinkText AutofitMode = "text" // shrink font/line-spacing to fit AutofitResizeShape AutofitMode = "shape" // grow the shape to fit the text )
Autofit modes.
type Bg ¶
Bg is p:bg (CT_Background): a slide's own background, overriding whatever its layout/master would otherwise supply. Only the simplest path — an explicit fill via BgPr — is modeled; bgRef (a reference into the theme's format-scheme background styles) is out of scope.
type BgPr ¶
type BgPr struct {
XMLName xml.Name `xml:"p:bgPr"`
Fill *drawingml.SolidFill `xml:"a:solidFill,omitempty"`
Gradient *drawingml.GradFill `xml:"a:gradFill,omitempty"`
}
BgPr is p:bgPr (CT_BackgroundProperties): the background's own fill. Fill and Gradient are the schema's EG_FillProperties choice: at most one should ever be set — Slide.Background/BackgroundScheme/BackgroundGradient enforce that by clearing the other whenever one is set.
type BlipFill ¶
type BlipFill struct {
XMLName xml.Name `xml:"p:blipFill"`
Blip *drawingml.Blip `xml:"a:blip"`
Stretch *drawingml.Stretch `xml:"a:stretch,omitempty"`
}
BlipFill is p:blipFill (CT_BlipFillProperties): the image reference and how it fills the picture's frame. In PresentationML the wrapper element is p:blipFill (not a:blipFill) even though both children stay in the "a:" namespace — the same host-names-the-element pattern as p:txBody wrapping drawingml.TextBody in Fase 2.
func NewBlipFill ¶
NewBlipFill returns a BlipFill referencing relID and stretched to fill its shape's whole frame — the simplest, and by far most common, image fill mode.
type CNvCxnSpPr ¶
type CNvCxnSpPr struct {
XMLName xml.Name `xml:"p:cNvCxnSpPr"`
StCxn *drawingml.StCxn `xml:"a:stCxn,omitempty"`
EndCxn *drawingml.EndCxn `xml:"a:endCxn,omitempty"`
}
CNvCxnSpPr is p:cNvCxnSpPr (CT_NonVisualConnectorProperties): connector-specific non-visual drawing properties. StCxn/EndCxn bind the connector's start/end points to another shape's connection site — see drawingml.StCxn's own doc comment for the index convention. CxnSpLocks (restricting move/resize in the authoring UI) is out of scope until a caller needs it.
type CNvGraphicFramePr ¶
type CNvGraphicFramePr struct {
XMLName xml.Name `xml:"p:cNvGraphicFramePr"`
GraphicFrameLocks *drawingml.GraphicFrameLocks `xml:"a:graphicFrameLocks,omitempty"`
}
CNvGraphicFramePr is p:cNvGraphicFramePr (CT_NonVisualGraphicFrameProperties): non-visual drawing properties specific to a graphic frame. GraphicFrameLocks is optional and unset by Slide.AddTable — nothing yet needs to restrict resize/move on a table.
type CNvPicPr ¶
type CNvPicPr struct {
XMLName xml.Name `xml:"p:cNvPicPr"`
PicLocks *drawingml.PicLocks `xml:"a:picLocks,omitempty"`
}
CNvPicPr is p:cNvPicPr (CT_NonVisualPictureProperties): picture-specific non-visual drawing properties. PicLocks is set to noChangeAspect="1" by every builder path so a placed image can't be stretched out of proportion in the authoring UI.
type CNvPr ¶
type CNvPr struct {
XMLName xml.Name `xml:"p:cNvPr"`
ID uint32 `xml:"id,attr"`
Name string `xml:"name,attr"`
}
CNvPr is p:cNvPr, the non-visual drawing properties (ID and name) shared by every shape-like element.
type CNvSpPr ¶
CNvSpPr is p:cNvSpPr, non-visual drawing properties specific to shapes. TxBox marks the shape as a text box rather than an auto-shape — required for PowerPoint to treat a bare rectangle as a text container.
type CSld ¶
type CSld struct {
XMLName xml.Name `xml:"p:cSld"`
Bg *Bg `xml:"p:bg,omitempty"`
SpTree *SpTree `xml:"p:spTree"`
}
CSld is p:cSld, the common slide data container: an optional background followed by the shape tree (plus, on slides only, an optional name attribute). Bg comes before SpTree in the struct because CT_CommonSlideData requires it there — bg is minOccurs=0, but when present it must precede the (always-required) spTree.
type ChartBuilder ¶
type ChartBuilder struct {
// contains filtered or unexported fields
}
ChartBuilder is a handle onto a chart placed via Slide.AddChart.
func (*ChartBuilder) AddSeries ¶
func (cb *ChartBuilder) AddSeries(name string, categories []string, values []float64) *SeriesBuilder
AddSeries adds a new data series to the chart.
func (*ChartBuilder) AxisTitles ¶
func (cb *ChartBuilder) AxisTitles(catTitle, valTitle string) *ChartBuilder
AxisTitles sets the titles for the category (X) and value (Y) axes.
func (*ChartBuilder) HasLegend ¶
func (cb *ChartBuilder) HasLegend(pos string) *ChartBuilder
HasLegend enables the chart legend at the specified position (e.g., "b" for bottom, "r" for right).
func (*ChartBuilder) SetBarDirection ¶
func (cb *ChartBuilder) SetBarDirection(dir string) *ChartBuilder
SetBarDirection sets the direction of a bar chart ("col" for vertical, "bar" for horizontal).
func (*ChartBuilder) SetGrouping ¶
func (cb *ChartBuilder) SetGrouping(grouping string) *ChartBuilder
SetGrouping sets the grouping of a bar/line chart ("clustered", "stacked", "percentStacked", "standard").
func (*ChartBuilder) SetHoleSize ¶
func (cb *ChartBuilder) SetHoleSize(size uint) *ChartBuilder
SetHoleSize sets the hole size percentage for a doughnut chart.
func (*ChartBuilder) Title ¶
func (cb *ChartBuilder) Title(title string) *ChartBuilder
Title sets the chart's title.
type ChartGraphic ¶
type ChartGraphic struct {
XMLName xml.Name `xml:"c:chart"`
XmlnsC string `xml:"xmlns:c,attr"`
XmlnsR string `xml:"xmlns:r,attr"`
RId string `xml:"r:id,attr"`
}
ChartGraphic represents the c:chart element embedded within a:graphicData.
type ClrMap ¶
type ClrMap struct {
XMLName xml.Name `xml:"p:clrMap"`
Bg1 string `xml:"bg1,attr"`
Tx1 string `xml:"tx1,attr"`
Bg2 string `xml:"bg2,attr"`
Tx2 string `xml:"tx2,attr"`
Accent1 string `xml:"accent1,attr"`
Accent2 string `xml:"accent2,attr"`
Accent3 string `xml:"accent3,attr"`
Accent4 string `xml:"accent4,attr"`
Accent5 string `xml:"accent5,attr"`
Accent6 string `xml:"accent6,attr"`
Hlink string `xml:"hlink,attr"`
FolHlink string `xml:"folHlink,attr"`
}
ClrMap is p:clrMap: the required color-slot mapping every slide master declares, assigning each of the 12 logical color-map slots to a theme scheme color. This is the conventional, near-universal default mapping.
func NewDefaultClrMap ¶
func NewDefaultClrMap() *ClrMap
NewDefaultClrMap returns the standard bg/tx-to-theme-slot mapping used by virtually every OOXML presentation.
type ClrMapOvr ¶
type ClrMapOvr struct {
XMLName xml.Name `xml:"p:clrMapOvr"`
MasterClrMapping *struct {
XMLName xml.Name `xml:"a:masterClrMapping"`
} `xml:"a:masterClrMapping"`
}
ClrMapOvr is p:clrMapOvr, present on every slide and slide layout: it either inherits the owning master's color map verbatim or overrides it. The walking skeleton always inherits.
func NewClrMapOvrInherit ¶
func NewClrMapOvrInherit() *ClrMapOvr
NewClrMapOvrInherit returns a ClrMapOvr that inherits the master's color map.
type ConnSite ¶
type ConnSite string
ConnSite names a connection site on a shape's own geometry, for use with Slide.Connect. rect, roundRect, and ellipse number their four cardinal connection sites 0 (top), 1 (left), 2 (bottom), 3 (right), counter-clockwise from the top — see drawingml.StCxn's own doc comment for how this was confirmed against a real render rather than assumed from the schema. Other presets number (and count) their sites differently in each shape's own cxnLst, so Slide.Connect only accepts endpoints drawn from connSiteGeom (the three verified above); see its doc comment.
type Connector ¶
type Connector struct {
XMLName xml.Name `xml:"p:cxnSp"`
NvCxnSpPr *NvCxnSpPr `xml:"p:nvCxnSpPr"`
SpPr *SpPr `xml:"p:spPr"`
}
Connector is p:cxnSp (CT_Connector): a line shape whose ends can be bound to connection sites on other shapes (see Slide.Connect) — unlike an ordinary autoshape's a:ln outline (ShapeRef.Border and friends), a bound connector's endpoints move with the shapes they're attached to when PowerPoint's own UI repositions them. Reuses *SpPr (the same xfrm/ prstGeom/ln every p:sp already carries) but has no txBody — CT_Connector itself defines none, so unlike Shape, a connector can never hold text. Field order mirrors the schema: nvCxnSpPr -> spPr.
type ConnectorRef ¶
type ConnectorRef struct {
// contains filtered or unexported fields
}
ConnectorRef is a handle onto a placed connector (a p:cxnSp), returned by Slide.Connect. It exposes the same line-styling methods ShapeRef does (Border, BorderScheme, BorderDash, LineCap, LineJoin, ArrowStart, ArrowEnd) via the shared apply*/build* helpers in text_builder.go — but is its own type, not a ShapeRef alias, since a connector has no txBody (see Connector's own doc comment) for AddParagraph and the other text-formatting methods to target.
func (*ConnectorRef) ArrowEnd ¶
func (cr *ConnectorRef) ArrowEnd(t ArrowheadType) *ConnectorRef
ArrowEnd is ArrowStart's counterpart for the connector's own bound end point.
func (*ConnectorRef) ArrowStart ¶
func (cr *ConnectorRef) ArrowStart(t ArrowheadType) *ConnectorRef
ArrowStart sets an arrowhead at the connector's own bound start point — see ShapeRef.ArrowStart for the prior-Border requirement and error behavior.
func (*ConnectorRef) Border ¶
func (cr *ConnectorRef) Border(c drawingml.Color, widthPoints float64) *ConnectorRef
Border sets the connector's line to a solid color at the given width, in points — see ShapeRef.Border for the width's valid range and error behavior.
func (*ConnectorRef) BorderDash ¶
func (cr *ConnectorRef) BorderDash(style DashStyle) *ConnectorRef
BorderDash sets the connector's line to a preset dash pattern — see ShapeRef.BorderDash for the prior-Border requirement and error behavior.
func (*ConnectorRef) BorderScheme ¶
func (cr *ConnectorRef) BorderScheme(scheme SchemeColor, widthPoints float64) *ConnectorRef
BorderScheme is Border's theme-color counterpart, referencing a scheme slot (e.g. SchemeAccent1) rather than an explicit RGB value.
func (*ConnectorRef) LineCap ¶
func (cr *ConnectorRef) LineCap(style LineCapStyle) *ConnectorRef
LineCap sets the connector's own end-cap style — see ShapeRef.LineCap for the prior-Border requirement and error behavior.
func (*ConnectorRef) LineJoin ¶
func (cr *ConnectorRef) LineJoin(style LineJoinStyle) *ConnectorRef
LineJoin sets the connector's own corner-join style (visible on a ConnBent/ConnCurved connector's own routed corners, not ConnStraight) — see ShapeRef.LineJoin for the prior-Border requirement and error behavior.
type ConnectorType ¶
type ConnectorType string
ConnectorType names a connector's own line geometry (a:prstGeom's prst attribute on a p:cxnSp, the same ST_ShapeType namespace AddShape's PresetGeometry draws from — but only the connector-shaped subset makes sense on a p:cxnSp), for use with Slide.Connect.
const ( ConnStraight ConnectorType = "line" // a direct line between the two connection sites ConnBent ConnectorType = "bentConnector3" // right-angled routing, PowerPoint's own default connector style ConnCurved ConnectorType = "curvedConnector3" // curved routing )
Common connector geometries. Any other connector-shaped ST_ShapeType name (e.g. "curvedConnector2") can still be passed as a plain ConnectorType("name") — this is a representative subset, the same convention PresetGeometry's own named constants use.
type DashStyle ¶
type DashStyle string
DashStyle names a preset line-dash pattern (a:prstDash's val attribute, ST_PresetLineDashVal) for use with ShapeRef.BorderDash.
const ( DashSolid DashStyle = "solid" DashDot DashStyle = "dot" DashDash DashStyle = "dash" DashLgDash DashStyle = "lgDash" DashDashDot DashStyle = "dashDot" DashLgDashDot DashStyle = "lgDashDot" DashLgDashDotDot DashStyle = "lgDashDotDot" DashSysDash DashStyle = "sysDash" DashSysDot DashStyle = "sysDot" DashSysDashDot DashStyle = "sysDashDot" DashSysDashDotDot DashStyle = "sysDashDotDot" )
Preset dash patterns, the complete ST_PresetLineDashVal enumeration.
type DefRPr ¶
type DefRPr struct {
XMLName xml.Name `xml:"a:defRPr"`
Sz int `xml:"sz,attr,omitempty"` // hundredths of a point
}
DefRPr is a:defRPr: default run (character) properties for a paragraph level.
type GradientStop ¶
type GradientStop struct {
Color drawingml.Color
Pos float64
Scheme SchemeColor
Tint float64
Shade float64
}
GradientStop is one color stop within a linear gradient (see ShapeRef.GradientFill / Slide.BackgroundGradient): a color at a position along the gradient's axis. Pos is a percentage from 0 (the gradient's start) to 100 (its end) — supply stops in ascending Pos order for a well-formed gradient; nothing enforces that order itself.
The stop's color is either an explicit RGB value (Color) or a theme color slot (Scheme). When Scheme is non-empty it takes precedence and the gradient stop follows the active theme (so a themed gradient recolors with WithTheme, just like FillScheme); leave Scheme empty ("") to use Color.
Tint (0-100) lightens the stop's color toward white; Shade (0-100) darkens it toward black — at most one should be set (both are rarely meaningful together); zero on both means no adjustment, applied whether the stop uses Color or Scheme.
Construct a GradientStop with keyed fields (e.g. GradientStop{Color: RGB(...), Pos: 0} or GradientStop{Scheme: SchemeAccent1, Pos: 0}), the form every call site here uses and that Go's vet composite check expects — Scheme, Tint, and Shade were all added as trailing optional fields, so keyed literals are unaffected.
type GraphicFrame ¶
type GraphicFrame struct {
XMLName xml.Name `xml:"p:graphicFrame"`
NvGraphicFramePr *NvGraphicFramePr `xml:"p:nvGraphicFramePr"`
Xfrm *GraphicFrameXfrm `xml:"p:xfrm"`
Graphic *drawingml.Graphic `xml:"a:graphic"`
}
GraphicFrame is p:graphicFrame (CT_GraphicalObjectFrame): a slide shape that wraps non-p:sp, non-p:pic content — today, only a table (see Slide.AddTable); charts and embedded OLE objects use this same wrapper in later phases. Field order mirrors the schema: nvGraphicFramePr -> xfrm -> graphic.
type GraphicFrameXfrm ¶
type GraphicFrameXfrm struct {
XMLName xml.Name `xml:"p:xfrm"`
Off *drawingml.Off `xml:"a:off,omitempty"`
Ext *drawingml.Ext `xml:"a:ext"`
}
GraphicFrameXfrm is p:xfrm: a graphic frame's position and size, in EMUs. It exists as its own type, rather than reusing drawingml.Xfrm, because Xfrm's own fixed XMLName ("a:xfrm") always wins over any field tag that tries to rename it — encoding/xml's rule, already documented on drawingml.TextBody. p:xfrm has the identical content model (a:CT_Transform2D); only the element's own namespace prefix differs, because a graphic frame is a PresentationML (p:) element while a shape's a:xfrm is reused verbatim across formats.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a handle onto a p:grpSp, returned by Slide.AddGroup. AddShape and AddTextBox mirror Slide's own methods of the same name, but append into the group's own Content instead of the slide's top-level shape tree — a member shape's (x, y) is still a slide-absolute EMU position (see AddGroup's own doc comment on the group's 1:1 child coordinate space), so no coordinate translation happens here.
func (*Group) AddShape ¶
func (g *Group) AddShape(prst PresetGeometry, x, y, w, h int) *ShapeRef
AddShape adds an autoshape to the group with the given preset geometry at the given position and size (x, y, w, h, all in EMUs, slide-absolute) — Slide.AddShape's counterpart for a group member. An invalid preset name is recorded as an error on the presentation (returned by Save), the same contract Slide.AddShape gives.
func (*Group) AddTextBox ¶
AddTextBox adds a text-box shape to the group at the given position and size (x, y, w, h, all in EMUs, slide-absolute) and returns a handle for adding paragraphs to it — Slide.AddTextBox's counterpart for a group member.
type GroupShape ¶
type GroupShape struct {
XMLName xml.Name `xml:"p:grpSp"`
NvGrpSpPr *NvGrpSpPr `xml:"p:nvGrpSpPr"`
GrpSpPr *GrpSpPr `xml:"p:grpSpPr"`
Content []any `xml:",any"`
}
GroupShape is p:grpSp (CT_GroupShape): a set of shapes that move, resize, and rotate together in PowerPoint's authoring UI. Structurally parallel to SpTree (nvGrpSpPr + grpSpPr + an ordered Content) but its own type, not a reuse of SpTree — SpTree's own fixed "p:spTree" XMLName can't be renamed to "p:grpSp" via a field tag (the same conflict this package's other new-type-per-tag types already document). Content is an order-preserving `[]any`, the same pattern SpTree.Content uses: CT_GroupShape's own EG_ShapeElements group structurally allows shapes, pictures, tables, nested groups, and connectors interleaved in any order, and there is no custom MarshalXML to reorder them. The Group handle currently only routes AddShape/AddTextBox (p:sp) into it; nesting a picture, table, or sub-group is a possible follow-up (each needs its own real-PowerPoint check that the element actually moves with the group).
type GrpSpPr ¶
type GrpSpPr struct {
XMLName xml.Name `xml:"p:grpSpPr"`
Xfrm *drawingml.GroupXfrm `xml:"a:xfrm,omitempty"`
}
GrpSpPr is p:grpSpPr (CT_GroupShapeProperties): a group shape's own properties. Xfrm is nil for the slide's root spTree (the walking skeleton's own usage — the root group never needs a non-identity child space) and set for a nested p:grpSp (see Slide.AddGroup), the only two contexts this type is used in. Fill/effect/3d properties are out of scope — a group's own visual properties are rarely set directly; its member shapes carry their own.
type LayoutType ¶
type LayoutType string
LayoutType names a slide layout's role (p:sldLayout's type attribute, ST_SlideLayoutType). Not exhaustive of the full ST_SlideLayoutType set — these are the standard layouts New() registers; see newStandardLayouts.
const ( LayoutBlank LayoutType = "blank" // no placeholders — pptxgo's original single layout LayoutTitleSlide LayoutType = "title" // centered title + subtitle LayoutTitleAndContent LayoutType = "obj" // title + one body placeholder LayoutSectionHeader LayoutType = "secHead" // title + body, section-break role LayoutTwoContent LayoutType = "twoObj" // title + two side-by-side body placeholders )
Standard layout types, in the order newStandardLayouts registers them.
type LineCapStyle ¶
type LineCapStyle string
LineCapStyle names a line's end-cap style (a:ln's cap attribute, ST_LineCap), for use with ShapeRef.LineCap.
const ( LineCapFlat LineCapStyle = "flat" LineCapRound LineCapStyle = "rnd" LineCapSquare LineCapStyle = "sq" )
The complete ST_LineCap enumeration.
type LineJoinStyle ¶
type LineJoinStyle string
LineJoinStyle names a line's corner-join style — how two of its segments meet at a corner — for use with ShapeRef.LineJoin.
const ( LineJoinRound LineJoinStyle = "round" LineJoinBevel LineJoinStyle = "bevel" LineJoinMiter LineJoinStyle = "miter" // Office's own default miter limit, 800% )
The three EG_LineJoinProperties choices.
type LvlPPr ¶
type LvlPPr struct {
Level int // 1-9; selects this level's element name — see MarshalXML
MarL *int
Indent *int
BuFont *drawingml.BuFont
BuNone *drawingml.BuNone
BuChar *drawingml.BuChar
DefRPr *DefRPr
}
LvlPPr is a:lvl1pPr through a:lvl9pPr (selected by Level, 1-9) — the same content model as drawingml.PPr (both are CT_TextParagraphProperties), but modeled as its own type: PPr's own fixed XMLName ("a:pPr") would win over a field tag if embedded directly, the same reuse trap TextStyle documents one level up, and unlike a:pPr this element also carries a trailing a:defRPr with the level's default run properties. A single type serves all nine levels (rather than nine near-identical structs) via MarshalXML choosing the element name from Level; field order within it mirrors the schema: MarL/Indent attrs, then BuFont ahead of the mutually-exclusive bullet group (BuNone/BuChar), then DefRPr last.
func (*LvlPPr) MarshalXML ¶
MarshalXML implements xml.Marshaler, naming the element a:lvl<Level>pPr. It rejects a Level outside 1-9 with an error rather than emitting an out-of-schema element name: the old fixed-XMLName Lvl1PPr made an invalid name structurally impossible, and since LvlPPr/TextStyle.Levels are exported (a caller can build a &LvlPPr{} directly, e.g. omitting Level so it defaults to 0, or setting 10+), that guarantee is re-established here. The error surfaces at Save time — pptxgo's own newBodyLevels/ NewDefaultTxStyles always set Level in range, so this only fires on caller-constructed styles.
type MergeData ¶
MergeData maps a placeholder name (the text between delimiters, e.g. "client_name" for the default "{{client_name}}") to its replacement text.
type MergeOption ¶
type MergeOption func(*mergeConfig)
MergeOption configures Template.Merge/OpenSlide.Merge.
func WithDelimiters ¶
func WithDelimiters(open, close string) MergeOption
WithDelimiters overrides Merge's placeholder delimiters (default "{{"/"}}").
func WithStrictMode ¶
func WithStrictMode() MergeOption
WithStrictMode makes Merge return an error if any placeholder found in the slide text has no matching key in the supplied data, instead of silently leaving that one placeholder untouched.
type Metadata ¶
type Metadata struct {
Title string // dc:title
Creator string // dc:creator — the author
Subject string // dc:subject
Keywords string // cp:keywords
Description string // dc:description
Category string // cp:category
LastModifiedBy string // cp:lastModifiedBy — defaults to Creator when empty
Company string // app.xml Company
Created time.Time
Modified time.Time
}
Metadata holds a presentation's document properties, written to docProps/core.xml (the Dublin Core / OPC core properties) and docProps/app.xml (extended properties). Every field is optional; empty strings and zero times are omitted. Set it with WithMetadata, or one field at a time with WithTitle/WithAuthor/WithSubject/WithKeywords/ WithDescription/WithCompany.
type NotesMasterId ¶
NotesMasterId is a single p:notesMasterId entry, referencing the notes master part via relationship ID.
type NotesMasterIdLst ¶
type NotesMasterIdLst struct {
XMLName xml.Name `xml:"p:notesMasterIdLst"`
Entries []*NotesMasterId `xml:"p:notesMasterId"`
}
NotesMasterIdLst is p:notesMasterIdLst, the (at most one, for pptxgo) list of notes masters.
type NotesSz ¶
type NotesSz struct {
XMLName xml.Name `xml:"p:notesSz"`
Cx int `xml:"cx,attr"`
Cy int `xml:"cy,attr"`
}
NotesSz is p:notesSz, the notes page canvas size in EMUs.
type NumberingScheme ¶
type NumberingScheme string
NumberingScheme names an automatic bullet-numbering scheme (a:buAutoNum's type attribute, ST_TextAutonumberScheme) for use with Paragraph.NumberedBullet.
const ( NumArabicPeriod NumberingScheme = "arabicPeriod" // "1.", "2.", ... NumArabicParenR NumberingScheme = "arabicParenR" // "1)", "2)", ... NumAlphaLcPeriod NumberingScheme = "alphaLcPeriod" // "a.", "b.", ... NumAlphaUcPeriod NumberingScheme = "alphaUcPeriod" // "A.", "B.", ... NumRomanLcPeriod NumberingScheme = "romanLcPeriod" // "i.", "ii.", ... NumRomanUcPeriod NumberingScheme = "romanUcPeriod" // "I.", "II.", ... )
Common numbering schemes.
type NvCxnSpPr ¶
type NvCxnSpPr struct {
XMLName xml.Name `xml:"p:nvCxnSpPr"`
CNvPr *CNvPr `xml:"p:cNvPr"`
CNvCxnSpPr *CNvCxnSpPr `xml:"p:cNvCxnSpPr"`
NvPr *NvPr `xml:"p:nvPr"`
}
NvCxnSpPr is p:nvCxnSpPr (CT_ConnectorNonVisual): a connector's non-visual properties — the same cNvPr/nvPr shape every other shape-like element carries (see NvSpPr, NvPicPr), plus cNvCxnSpPr for the connection bindings.
type NvGraphicFramePr ¶
type NvGraphicFramePr struct {
XMLName xml.Name `xml:"p:nvGraphicFramePr"`
CNvPr *CNvPr `xml:"p:cNvPr"`
CNvGraphicFramePr *CNvGraphicFramePr `xml:"p:cNvGraphicFramePr"`
NvPr *NvPr `xml:"p:nvPr"`
}
NvGraphicFramePr is p:nvGraphicFramePr (CT_GraphicalObjectFrameNonVisual): the graphic frame's non-visual properties — the same cNvPr/nvPr shape every other shape-like element carries (see NvSpPr, NvPicPr).
type NvGrpSpPr ¶
type NvGrpSpPr struct {
XMLName xml.Name `xml:"p:nvGrpSpPr"`
CNvPr *CNvPr `xml:"p:cNvPr"`
CNvGrpSpPr *struct {
XMLName xml.Name `xml:"p:cNvGrpSpPr"`
} `xml:"p:cNvGrpSpPr"`
NvPr *struct {
XMLName xml.Name `xml:"p:nvPr"`
} `xml:"p:nvPr"`
}
NvGrpSpPr is p:nvGrpSpPr, the shape tree's own (required, always-empty group) non-visual properties.
type NvPicPr ¶
type NvPicPr struct {
XMLName xml.Name `xml:"p:nvPicPr"`
CNvPr *CNvPr `xml:"p:cNvPr"`
CNvPicPr *CNvPicPr `xml:"p:cNvPicPr"`
NvPr *NvPr `xml:"p:nvPr"`
}
NvPicPr is p:nvPicPr (CT_PictureNonVisual): the picture's non-visual properties.
type NvPr ¶
NvPr is p:nvPr: placeholder-linkage information shared by every shape's non-visual properties. Ph is nil for an ordinary shape; set, it marks this shape as a placeholder — see Ph.
type NvSpPr ¶
type NvSpPr struct {
XMLName xml.Name `xml:"p:nvSpPr"`
CNvPr *CNvPr `xml:"p:cNvPr"`
CNvSpPr *CNvSpPr `xml:"p:cNvSpPr"`
NvPr *NvPr `xml:"p:nvPr"`
}
NvSpPr is p:nvSpPr (CT_ShapeNonVisual): the shape's non-visual properties.
type OpenSlide ¶
type OpenSlide struct {
// contains filtered or unexported fields
}
OpenSlide is a handle onto one slide within an opened Template, returned by Template.Slide/Slides.
func (*OpenSlide) Merge ¶
func (s *OpenSlide) Merge(data MergeData, opts ...MergeOption) (int, error)
Merge substitutes placeholders on just this slide — see Template.Merge.
func (*OpenSlide) Replace ¶
Replace performs a literal substring replacement on just this slide — see Template.Replace, including why an empty old is an error.
func (*OpenSlide) Text ¶
Text returns every run of text on the slide, in document order, one paragraph per line. Unlike Replace/Merge (substitute.go), this needs no run-consolidation: concatenating a:t content in document order reconstructs the right text even when PowerPoint has split it across several <a:r> runs (autocorrect, proofing, formatting boundaries) — a straddling run boundary only breaks pattern MATCHING (e.g. finding a literal "{{key}}" span), not plain concatenation.
type Option ¶
type Option func(*presentationConfig)
Option configures a Presentation at construction time, for use with New.
func WithAuthor ¶
WithAuthor sets the document author (dc:creator). Unless WithMetadata also sets LastModifiedBy, the author is used as the last-modified-by too.
func WithCompany ¶
WithCompany sets the company (docProps/app.xml Company).
func WithDescription ¶
WithDescription sets the document description/comments (dc:description).
func WithKeywords ¶
WithKeywords sets the document keywords (cp:keywords).
func WithMetadata ¶
WithMetadata sets the presentation's document properties (docProps/core.xml and docProps/app.xml) all at once. The single-field options below (WithTitle, WithAuthor, ...) set individual members and compose with this in call order.
func WithSlideSize ¶
WithSlideSize overrides New's default 16:9 widescreen canvas (13.333in x 7.5in) with an explicit width and height, in EMUs (see the Inches helper) — including a portrait layout, by simply passing a height greater than the width. The resulting p:sldSz carries no type attribute, since ST_SlideSizeType names a fixed set of standard sizes and an arbitrary custom size doesn't correspond to any of them. A dimension outside ST_SlideSizeCoordinate's 914400-51206400 EMU range (1in to 56in) is recorded as an error on the presentation (returned by Save) and leaves New's own default size in effect.
func WithStandard4x3 ¶
func WithStandard4x3() Option
WithStandard4x3 sets the slide canvas to the pre-2013 PowerPoint default, 10in x 7.5in (4:3), instead of New's own 16:9 widescreen default.
func WithSubject ¶
WithSubject sets the document subject (dc:subject).
func WithTheme ¶
WithTheme brands the whole deck with t's color scheme and font scheme (ppt/theme/theme1.xml). Because every fill, border, text color, and background can reference a theme slot by name (SchemeColor with FillScheme/ BorderScheme/ColorScheme/BackgroundScheme) rather than a hardcoded RGB, one WithTheme recolors all of them at once. Omitting it applies DefaultTheme (Office's palette and typography). See Theme, DefaultTheme.
type Paragraph ¶
type Paragraph struct {
// contains filtered or unexported fields
}
Paragraph is a handle onto a single a:p, returned by TextBox.AddParagraph. Text starts one or more new runs (a "\n" in the given string splits it into multiple runs with an explicit a:br between them — PowerPoint does not treat a literal newline inside a run's text as a line break). The run-formatting methods (Bold, Italic, Underline, FontSize, Font, Color) apply to every run Text most recently started, so a single paragraph can mix differently-formatted runs by calling Text again in between. Alignment applies to the paragraph as a whole and can be called at any point in the chain.
func (*Paragraph) Bullet ¶
Bullet sets this paragraph's bullet to an explicit character (e.g. "•"), drawn in the given font (e.g. "Arial") — PowerPoint needs that font declared alongside the character, or the bullet renders as a missing-glyph box. Explicit only: this is a per-paragraph override, not the master-inherited bullet a placeholder would otherwise pick up.
func (*Paragraph) ColorScheme ¶
func (pg *Paragraph) ColorScheme(scheme SchemeColor) *Paragraph
ColorScheme sets the current run(s)' text color to a theme color, referenced by scheme slot (e.g. SchemeAccent1) rather than an explicit RGB value.
func (*Paragraph) FontSize ¶
FontSize sets the current run(s)' font size, in points (1-4000, matching the schema's centipoint range of 100-400000; half-points such as 10.5 are valid). Formatting calls made before any Text call are a documented no-op — including this validation, so FontSize(5000) before Text does not record an error. An out-of-range value called with a current run present is recorded as an error on the presentation (returned by Save) and leaves the run(s)' size unset.
func (*Paragraph) Hyperlink ¶
Hyperlink makes the current run(s) a clickable hyperlink to the given external URL. Like Text and the other run-formatting methods, it applies to whichever run(s) the most recent Text call started, and is a no-op if called before any Text call. The relationship is scoped to the owning slide's own .rels, the same pattern AddImage already established for media.
func (*Paragraph) Indent ¶
Indent sets the paragraph's left margin and first-line indent, both in points. A negative firstLine produces a hanging indent — the common bulleted-text layout where the bullet sits to the left of wrapped text.
func (*Paragraph) Lang ¶
Lang sets the current run(s)' language (BCP 47, e.g. "fr", "en-US") — used by PowerPoint for spell-checking and hyphenation of just that run, e.g. a foreign-language phrase inside an otherwise single-language paragraph. A run without a Lang call inherits the presentation/theme default. No format validation is performed here, matching Font/Color; callers that need BCP 47 well-formedness should validate before calling.
func (*Paragraph) Level ¶
Level sets the paragraph's outline level (0-8, PowerPoint's UI levels 1-9, matching ST_TextIndentLevelType's range), which controls indent and bullet inheritance from the list style. A value outside 0-8 is recorded as an error on the presentation (returned by Save) and leaves the level unset.
func (*Paragraph) LineSpacing ¶
LineSpacing sets this paragraph's line spacing as a percentage of single spacing (100 = single, 150 = 1.5x, 200 = double).
func (*Paragraph) NumberedBullet ¶
func (pg *Paragraph) NumberedBullet(scheme NumberingScheme) *Paragraph
NumberedBullet sets this paragraph's bullet to an automatically numbered scheme (e.g. NumArabicPeriod for "1.", "2.", ...), starting at 1.
func (*Paragraph) NumberedBulletFrom ¶
func (pg *Paragraph) NumberedBulletFrom(scheme NumberingScheme, startAt int) *Paragraph
NumberedBulletFrom is NumberedBullet with an explicit starting number (a:buAutoNum's startAt) — for a list that continues from a previous one (e.g. a second column resuming at 4). startAt must be in ST_TextAutonumberStartAt's 1-32767 range; an out-of-range value is recorded as an error on the presentation (returned by Save) and leaves the paragraph's bullet unset. startAt of 1 is the scheme's own default, so it behaves identically to NumberedBullet.
func (*Paragraph) SpaceAfter ¶
SpaceAfter sets the space after this paragraph, in points.
func (*Paragraph) SpaceBefore ¶
SpaceBefore sets the space before this paragraph, in points.
type Ph ¶
type Ph struct {
XMLName xml.Name `xml:"p:ph"`
Type PlaceholderType `xml:"type,attr,omitempty"`
Idx uint32 `xml:"idx,attr,omitempty"`
}
Ph is p:ph (CT_Placeholder): marks a shape as a placeholder, linking it by Type+Idx to the correspondingly-typed placeholder in this part's layout (and, from there, the master) for position/formatting inheritance — a slide (or layout) placeholder that sets no a:xfrm of its own inherits the layout's (or master's). Idx is the schema's own ST_PlaceholderIndex default of 0 when unset (plain uint32 + omitempty, not *int — unlike MarL/Lvl/Indent elsewhere, 0 here is genuinely "not set, use the default" rather than a meaningful explicit value), so a title or single-body placeholder never needs to set it; only a second placeholder of the same type on one slide (e.g. a two-content layout's second body) needs a distinct idx. uint32, not int: ST_PlaceholderIndex is xsd:unsignedInt, so a negative value would be schema-invalid — the type itself rules that out rather than needing a runtime check.
type Picture ¶
type Picture struct {
XMLName xml.Name `xml:"p:pic"`
NvPicPr *NvPicPr `xml:"p:nvPicPr"`
BlipFill *BlipFill `xml:"p:blipFill"`
SpPr *SpPr `xml:"p:spPr"`
}
Picture is p:pic (CT_Picture): an image placed directly on a slide. Field order mirrors the schema: nvPicPr -> blipFill -> spPr.
type PictureRef ¶
type PictureRef struct {
// contains filtered or unexported fields
}
PictureRef is a handle onto a placed image (a p:pic), returned by Slide.AddImage and its variants. Border is its only formatting method — an image has no text and no separate fill (its "fill" is the image itself, via blipFill).
func (*PictureRef) Border ¶
func (p *PictureRef) Border(c drawingml.Color, widthPoints float64) *PictureRef
Border sets the picture's outline to a solid color at the given width, in points (e.g. 0.75, 1.5; 0-1584, matching ST_LineWidth's 0-20,116,800 EMU range). An out-of-range width is recorded as an error on the presentation (returned by Save) and leaves the border unset.
func (*PictureRef) Glow ¶
func (p *PictureRef) Glow(c drawingml.Color, radiusPoints float64) *PictureRef
Glow is ShapeRef.Glow's counterpart for a placed image.
func (*PictureRef) Reflection ¶
func (p *PictureRef) Reflection(startOpacityPercent float64) *PictureRef
Reflection is ShapeRef.Reflection's counterpart for a placed image.
func (*PictureRef) Shadow ¶
func (p *PictureRef) Shadow(c drawingml.Color, alphaPercent float64) *PictureRef
Shadow is ShapeRef.Shadow's counterpart for a placed image.
func (*PictureRef) SoftEdges ¶
func (p *PictureRef) SoftEdges(radiusPoints float64) *PictureRef
SoftEdges is ShapeRef.SoftEdges's counterpart for a placed image.
type PlaceholderType ¶
type PlaceholderType string
PlaceholderType names a placeholder's role (p:ph's type attribute, ST_PlaceholderType) — which same-typed, same-idx placeholder in a layout, and from there its master, a placeholder that omits its own position/formatting inherits from. Not exhaustive of ST_PlaceholderType's full set (which also names notes/date/footer/slide-number placeholders, among others) — these are the ones pptxgo's own master and standard layouts use.
const ( PlaceholderTitle PlaceholderType = "title" // main slide title PlaceholderCtrTitle PlaceholderType = "ctrTitle" // centered title (title-slide layout) PlaceholderSubTitle PlaceholderType = "subTitle" // subtitle (title-slide layout) PlaceholderBody PlaceholderType = "body" // bulleted body text PlaceholderDate PlaceholderType = "dt" // date, in the footer row (see Slide.DateText) PlaceholderSlideNumber PlaceholderType = "sldNum" // slide-number field (see Slide.SlideNumber) )
Placeholder types.
type Presentation ¶
type Presentation struct {
// contains filtered or unexported fields
}
Presentation is a PresentationML document under construction: one theme, one slide master, and one slide layout — the structural backbone every presentation needs regardless of slide count — plus whatever slides AddSlide adds. New() starts with zero slides.
func New ¶
func New(opts ...Option) *Presentation
New builds a presentation with its theme, slide master, and slide layout already wired, and no slides. Call AddSlide to add content. With no options, the slide canvas is 16:9 widescreen; pass WithSlideSize or WithStandard4x3 to override it.
func (*Presentation) AddSlide ¶
func (p *Presentation) AddSlide(opts ...SlideOption) *Slide
AddSlide appends a new, empty slide and returns a handle for adding shapes and placeholders to it. With no options it uses LayoutBlank, the presentation's original single layout; pass WithLayout to pick one of the others (see LayoutType).
type PresetGeometry ¶
type PresetGeometry string
PresetGeometry names a preset autoshape outline (a:prstGeom's prst attribute, schema type ST_ShapeType) for use with Slide.AddShape. This is a representative subset of the ~180 shapes ST_ShapeType allows; any other valid preset name can still be passed as a plain PresetGeometry("name").
const ( ShapeLine PresetGeometry = "line" ShapeRect PresetGeometry = "rect" ShapeRoundRect PresetGeometry = "roundRect" ShapeEllipse PresetGeometry = "ellipse" ShapeTriangle PresetGeometry = "triangle" ShapeRightTriangle PresetGeometry = "rtTriangle" ShapeParallelogram PresetGeometry = "parallelogram" ShapeTrapezoid PresetGeometry = "trapezoid" ShapeDiamond PresetGeometry = "diamond" ShapePentagon PresetGeometry = "pentagon" ShapeHexagon PresetGeometry = "hexagon" ShapeHeptagon PresetGeometry = "heptagon" ShapeOctagon PresetGeometry = "octagon" ShapeStar4 PresetGeometry = "star4" ShapeStar5 PresetGeometry = "star5" ShapeStar6 PresetGeometry = "star6" ShapeStar8 PresetGeometry = "star8" ShapeRightArrow PresetGeometry = "rightArrow" ShapeLeftArrow PresetGeometry = "leftArrow" ShapeUpArrow PresetGeometry = "upArrow" ShapeDownArrow PresetGeometry = "downArrow" ShapeLeftRightArrow PresetGeometry = "leftRightArrow" ShapeUpDownArrow PresetGeometry = "upDownArrow" ShapeChevron PresetGeometry = "chevron" ShapeDonut PresetGeometry = "donut" ShapeNoSmoking PresetGeometry = "noSmoking" ShapeHeart PresetGeometry = "heart" ShapeLightningBolt PresetGeometry = "lightningBolt" ShapeSun PresetGeometry = "sun" ShapeMoon PresetGeometry = "moon" ShapeCloud PresetGeometry = "cloud" ShapeArc PresetGeometry = "arc" ShapePlaque PresetGeometry = "plaque" ShapeCan PresetGeometry = "can" ShapeCube PresetGeometry = "cube" ShapeBevel PresetGeometry = "bevel" ShapeSmileyFace PresetGeometry = "smileyFace" ShapeWave PresetGeometry = "wave" ShapeDoubleWave PresetGeometry = "doubleWave" )
Common preset geometries.
type SchemeColor ¶
type SchemeColor string
SchemeColor references a color slot in the active theme's color scheme (a:schemeClr's val attribute, ST_SchemeColorVal — the slots the theme's own a:clrScheme defines) rather than an explicit RGB value, so a fill/border/text color automatically follows the theme. For use with ShapeRef.FillScheme, ShapeRef.BorderScheme, Paragraph.ColorScheme, and Slide.BackgroundScheme.
const ( SchemeDark1 SchemeColor = "dk1" SchemeLight1 SchemeColor = "lt1" SchemeDark2 SchemeColor = "dk2" SchemeLight2 SchemeColor = "lt2" SchemeBackground1 SchemeColor = "bg1" SchemeText1 SchemeColor = "tx1" SchemeBackground2 SchemeColor = "bg2" SchemeText2 SchemeColor = "tx2" SchemeAccent1 SchemeColor = "accent1" SchemeAccent2 SchemeColor = "accent2" SchemeAccent3 SchemeColor = "accent3" SchemeAccent4 SchemeColor = "accent4" SchemeAccent5 SchemeColor = "accent5" SchemeAccent6 SchemeColor = "accent6" SchemeHyperlink SchemeColor = "hlink" SchemeFollowedHyperlink SchemeColor = "folHlink" )
Theme color scheme slots. dk1/lt1/dk2/lt2 are the slots the theme's own a:clrScheme defines directly; bg1/tx1/bg2/tx2 are the same four slots under the aliases a slide's own p:clrMap maps them through (bg1->lt1, tx1->dk1, bg2->lt2, tx2->dk2, in pptxgo's default color map — see NewDefaultClrMap) — both forms are valid ST_SchemeColorVal values.
type SeriesBuilder ¶
type SeriesBuilder struct {
// contains filtered or unexported fields
}
SeriesBuilder is a handle to a chart series to configure its properties.
func (*SeriesBuilder) Color ¶
func (sb *SeriesBuilder) Color(hex string) *SeriesBuilder
Color sets a custom solid fill color (hex format, e.g., "FF0000") for the series.
func (*SeriesBuilder) DataLabels ¶
func (sb *SeriesBuilder) DataLabels(showVal, showCat, showSer, showPercent bool) *SeriesBuilder
DataLabels enables data labels for this series.
type Shape ¶
type Shape struct {
XMLName xml.Name `xml:"p:sp"`
NvSpPr *NvSpPr `xml:"p:nvSpPr"`
SpPr *SpPr `xml:"p:spPr"`
TxBody *drawingml.TextBody `xml:"p:txBody,omitempty"`
}
Shape is p:sp (CT_Shape): a single shape on a slide. Fase 2 only ever builds the text-box flavor (a rectangle with a txBody), but the wrapper models the full shape schema so pictures and placeholders can reuse it in later phases.
type ShapeRef ¶
type ShapeRef struct {
// contains filtered or unexported fields
}
ShapeRef is a handle onto any p:sp shape on a slide — a text box (Slide.AddTextBox) or an arbitrary autoshape (Slide.AddShape). AddParagraph adds text content; Fill and Border set the shape's own background and outline; Rotation, FlipH, and FlipV set its transform. TextBox is an alias: a text box is simply a ShapeRef whose geometry defaults to rect.
func (*ShapeRef) AddParagraph ¶
AddParagraph appends a new, empty paragraph to the shape and returns a handle for adding runs and formatting to it.
func (*ShapeRef) Adjust ¶
Adjust sets a preset geometry's adjust value (an a:avLst/a:gd guide) — the parametric handle that reshapes some autoshapes, e.g. the corner radius of a ShapeRoundRect or the notch depth of a ShapeChevron. name is the guide's name ("adj" for a single-handle shape, or "adj1"/"adj2"/... for shapes with several) and value is its adjust coordinate — for the common fraction-valued handles, in thousandths of a percent (e.g. 25000 rounds a ShapeRoundRect's corners to 25% of the shorter side). Repeated calls append distinct guides; calling Adjust again with the same name overwrites it.
A placeholder that inherits its geometry (Slide.AddPlaceholder) has no preset geometry of its own to adjust — calling Adjust on it records an error on the presentation (returned by Save), the same contract Rotation gives for inherited transforms.
func (*ShapeRef) Anchor ¶
func (sr *ShapeRef) Anchor(a VerticalAnchor) *ShapeRef
Anchor sets the text body's vertical alignment within the shape.
func (*ShapeRef) ArrowEnd ¶
func (sr *ShapeRef) ArrowEnd(t ArrowheadType) *ShapeRef
ArrowEnd is ArrowStart's counterpart for the end of the shape's outline path.
func (*ShapeRef) ArrowStart ¶
func (sr *ShapeRef) ArrowStart(t ArrowheadType) *ShapeRef
ArrowStart sets an arrowhead (or other line-end decoration) at the beginning of the shape's outline path — ArrowEnd is its counterpart at the end. Only visible on an open shape's outline (e.g. ShapeLine) — a closed autoshape's path has no defined start/end. Border or BorderScheme must be called first — see LineCap for the same requirement and error contract. Size uses Office's own default ("med") for both width and length.
func (*ShapeRef) Autofit ¶
func (sr *ShapeRef) Autofit(mode AutofitMode) *ShapeRef
Autofit sets how the shape's text behaves when it overflows the shape's bounds.
func (*ShapeRef) Border ¶
Border sets the shape's outline to a solid color at the given width, in points (e.g. 0.75, 1.5; 0-1584, matching ST_LineWidth's 0-20,116,800 EMU range). An out-of-range width is recorded as an error on the presentation (returned by Save) and leaves the border unset.
func (*ShapeRef) BorderDash ¶
BorderDash sets the shape's outline to a preset dash pattern (e.g. DashDash, DashSysDot). Border or BorderScheme must be called first to give the shape an outline to dash — calling BorderDash before either records an error on the presentation (returned by Save) instead of silently no-oping, the same contract requireXfrm gives Rotation/FlipH/FlipV. An unrecognized preset is likewise recorded as an error and leaves the dash pattern unset.
func (*ShapeRef) BorderScheme ¶
func (sr *ShapeRef) BorderScheme(scheme SchemeColor, widthPoints float64) *ShapeRef
BorderScheme sets the shape's outline to a theme color, referenced by scheme slot (e.g. SchemeAccent1), at the given width in points — see Border for the width's valid range.
func (*ShapeRef) FillScheme ¶
func (sr *ShapeRef) FillScheme(scheme SchemeColor) *ShapeRef
FillScheme sets the shape's background to a theme color, referenced by scheme slot (e.g. SchemeAccent1) rather than an explicit RGB value.
func (*ShapeRef) Glow ¶
Glow adds a soft-edged color halo around the shape's own outline. radiusPoints is the glow's radius, in points. A negative value is recorded as an error on the presentation (returned by Save) and leaves the effect unset.
func (*ShapeRef) GradientFill ¶
func (sr *ShapeRef) GradientFill(angleDegrees float64, stops ...GradientStop) *ShapeRef
GradientFill sets the shape's background to a linear gradient blending through the given color stops (at least 2 required — the schema's own minimum), its axis rotated by angleDegrees clockwise (the same convention as Rotation: 0 runs left-to-right, 90 top-to-bottom). An invalid angle or an out-of-range stop is recorded as an error on the presentation (returned by Save) and leaves the fill unset.
func (*ShapeRef) Insets ¶
Insets sets the text body's internal margins (the gap between the shape's outline and its text), all in points.
func (*ShapeRef) LineCap ¶
func (sr *ShapeRef) LineCap(style LineCapStyle) *ShapeRef
LineCap sets the shape's outline end-cap style. Border or BorderScheme must be called first to give the shape an outline to style — the same prior-Border requirement and error contract BorderDash gives. An unrecognized style is likewise recorded as an error and leaves the cap unset.
func (*ShapeRef) LineJoin ¶
func (sr *ShapeRef) LineJoin(style LineJoinStyle) *ShapeRef
LineJoin sets the shape's outline corner-join style — how two of the outline's segments meet at a corner (visible only on a shape with actual corners, e.g. ShapeRect, not ShapeEllipse). Border or BorderScheme must be called first — see LineCap for the same requirement and error contract. LineJoinMiter uses Office's own default miter limit (800%, matching the built-in theme's own line styles — see themeFmtScheme).
func (*ShapeRef) NoFill ¶
NoFill removes the shape's fill entirely — distinct from never calling Fill, which lets the shape inherit one from its style or layout instead.
func (*ShapeRef) Reflection ¶
Reflection adds a mirror-image reflection beneath the shape, fading from startOpacityPercent at the shape's own edge to fully transparent. startOpacityPercent must be 0-100; an out-of-range value is recorded as an error on the presentation (returned by Save) and leaves the effect unset. The mirror flip comes from the emitted sy=-100000 (see Reflection's own doc comment) — an earlier version omitted it and rendered nothing in any viewer despite passing the SDK validator. LibreOffice still does not render a:reflection; confirmed visible in real PowerPoint.
func (*ShapeRef) Rotation ¶
Rotation sets the shape's rotation, in degrees clockwise (e.g. 45, -90; any value works, including beyond a full turn — 405 is the same rotation as 45). AddShape and AddTextBox always give a shape its own a:xfrm, so this is never a no-op for them; a placeholder from Slide.AddPlaceholder/Title/Body has no a:xfrm of its own (see WithLayout) and so has nothing to rotate — see the shared nil-Xfrm handling this calls into.
func (*ShapeRef) Shadow ¶
Shadow adds a soft drop shadow behind the shape, using Office's own built-in outer-shadow preset (see newOuterShdw). alphaPercent is the shadow color's opacity, 0-100 (Office's own preset uses 63). An out-of-range value is recorded as an error on the presentation (returned by Save) and leaves the effect unset.
type SldId ¶
type SldId struct {
XMLName xml.Name `xml:"p:sldId"`
ID uint32 `xml:"id,attr"`
RID string `xml:"r:id,attr"`
}
SldId is a single p:sldId entry, referencing a slide part via relationship ID.
type SldLayoutId ¶
type SldLayoutId struct {
XMLName xml.Name `xml:"p:sldLayoutId"`
ID uint32 `xml:"id,attr"`
RID string `xml:"r:id,attr"`
}
SldLayoutId is a single p:sldLayoutId entry.
type SldLayoutIdLst ¶
type SldLayoutIdLst struct {
XMLName xml.Name `xml:"p:sldLayoutIdLst"`
Entries []*SldLayoutId `xml:"p:sldLayoutId"`
}
SldLayoutIdLst is p:sldLayoutIdLst: the list of layouts owned by a master.
type SldMasterId ¶
type SldMasterId struct {
XMLName xml.Name `xml:"p:sldMasterId"`
ID uint32 `xml:"id,attr"`
RID string `xml:"r:id,attr"`
}
SldMasterId is a single p:sldMasterId entry, referencing a slideMaster part via relationship ID.
type SldMasterIdLst ¶
type SldMasterIdLst struct {
XMLName xml.Name `xml:"p:sldMasterIdLst"`
Entries []*SldMasterId `xml:"p:sldMasterId"`
}
SldMasterIdLst is p:sldMasterIdLst, the list of slide masters.
type SldSz ¶
type SldSz struct {
XMLName xml.Name `xml:"p:sldSz"`
Cx int `xml:"cx,attr"`
Cy int `xml:"cy,attr"`
Type string `xml:"type,attr,omitempty"`
}
SldSz is p:sldSz, the slide canvas size in EMUs.
type Slide ¶
type Slide struct {
// contains filtered or unexported fields
}
Slide is a handle onto one already-registered slide part: the entry point for adding shapes to it. Obtain one via Presentation.AddSlide; the zero value is not usable.
func (*Slide) AddChart ¶
func (s *Slide) AddChart(chartType ChartType, x, y, w, h int) *ChartBuilder
AddChart adds a chart to the slide at the given position and size (x, y, w, h).
func (*Slide) AddGroup ¶
AddGroup adds a group shape (p:grpSp) at the given position and size (x, y, w, h, all in EMUs) and returns a handle for adding member shapes to it — a set of shapes that move, resize, and rotate together in PowerPoint's authoring UI, the same "Group" operation PowerPoint's own UI offers. The group's child coordinate space starts 1:1 with the slide's own (chOff=off, chExt=ext — see drawingml.GroupXfrm's own doc comment for the mapping this makes an identity function): a shape added via Group.AddShape at, say, Inches(2), Inches(2) lands at exactly that slide position, the same as it would outside the group — no separate coordinate system to reason about. x, y, w, h set the group's own visible bounding box; PowerPoint's own "Group" operation computes this box to exactly enclose the member shapes, but pptxgo does not (member shapes are added after AddGroup returns, so their extent isn't known yet) — pick a box that covers where the members will actually be, or PowerPoint's on-open "repair" may adjust it.
func (*Slide) AddImage ¶
func (s *Slide) AddImage(path string, x, y int) *PictureRef
AddImage adds an image at (x, y), both in EMUs, auto-sized from the image's own pixel dimensions at 96 DPI. Format (PNG, JPEG, or GIF) is auto-detected. For exact sizing use AddImageWithSize.
func (*Slide) AddImageFromBytes ¶
func (s *Slide) AddImageFromBytes(data []byte, x, y int) *PictureRef
AddImageFromBytes adds an in-memory image (PNG, JPEG, or GIF, format auto-detected) at (x, y), auto-sized from its pixel dimensions at 96 DPI. Empty data records an error on the presentation (returned by Save).
func (*Slide) AddImageFromBytesWithSize ¶
func (s *Slide) AddImageFromBytesWithSize(data []byte, x, y, w, h int) *PictureRef
AddImageFromBytesWithSize adds an in-memory image at (x, y) with an explicit size (w, h), all in EMUs — including a (0, 0) size, which is used as given rather than falling back to auto-sizing. Empty data records an error on the presentation (returned by Save).
func (*Slide) AddImageWithSize ¶
func (s *Slide) AddImageWithSize(path string, x, y, w, h int) *PictureRef
AddImageWithSize adds an image at (x, y) with an explicit size (w, h), all in EMUs — including a (0, 0) size, which is used as given rather than falling back to auto-sizing. Format is auto-detected; the image's own pixel dimensions are otherwise ignored in favor of w and h.
func (*Slide) AddPlaceholder ¶
func (s *Slide) AddPlaceholder(phType PlaceholderType, idx uint32) *ShapeRef
AddPlaceholder adds a placeholder shape of the given type and index (see PlaceholderType; idx distinguishes multiple placeholders of the same type, e.g. a Two Content layout's second body — pass 0 for a type that only ever appears once, like title) and returns a handle for adding text. Unlike AddShape/AddTextBox, the returned shape has no a:xfrm of its own: a placeholder inherits its position and size from the same-typed, same-idx placeholder in the slide's own layout (and, from there, the master) — see WithLayout. Pairing a placeholder type/idx that the slide's layout doesn't declare still produces schema-valid XML, but PowerPoint has nothing to inherit position from and places it arbitrarily; Title and Body cover the common case of a type/idx a standard layout does declare.
A type+idx pair already used on this slide is rejected (an error recorded on the presentation, returned by Save) rather than emitting a second placeholder with the same key: PowerPoint keys placeholders by type+idx, so a duplicate is schema-valid XML that PowerPoint still treats as corrupt and "repairs" on open, silently dropping one placeholder's content. The returned ShapeRef is still safe to chain off of in that case — it targets a detached shape, not one on the slide.
func (*Slide) AddShape ¶
func (s *Slide) AddShape(prst PresetGeometry, x, y, w, h int) *ShapeRef
AddShape adds an autoshape with the given preset geometry (see the Shape* constants, e.g. ShapeEllipse — any of ST_ShapeType's 187 names is accepted, not only those with a named constant) at the given position and size (x, y, w, h, all in EMUs — see the Inches/Points helpers), and returns a handle for adding text content and setting fill/border/ rotation/flip. A name outside ST_ShapeType is recorded as an error on the presentation (returned by Save), since a:prstGeom/@prst with an unrecognized value is a file PowerPoint refuses to open.
func (*Slide) AddTable ¶
AddTable adds a rows x cols table at the given position and overall size (x, y, w, h, all in EMUs — see the Inches/Points helpers), with column widths and row heights initially split evenly across w and h, and returns a handle for setting cell content and column/row sizing. Every cell starts with an empty txBody, the same "always at least one a:p" schema guarantee AddTextBox gives a fresh text box (drawingml.TextBody's own MarshalXML fills it in even without an explicit AddParagraph call).
Unlike a shape or picture, a table is wrapped in a p:graphicFrame, not a p:sp — a:tbl content lives entirely inline in the slide's own XML, with no separate part or relationship the way an image needs one.
rows and cols must both be positive (a table needs at least one of each to mean anything); a non-positive value is recorded as an error on the presentation (returned by Save) rather than dividing width/height by zero, and is clamped to 1 so the rest of this method — and the *Table it returns — has a well-formed table to build, even though Save will refuse to write it.
func (*Slide) AddTextBox ¶
AddTextBox adds a text-box shape at the given position and size (x, y, w, h, all in EMUs — see the Inches/Points helpers) and returns a handle for adding paragraphs to it. It is addShape with a rect outline and the txBox marker set — the same p:sp any other autoshape uses.
func (*Slide) Background ¶
Background sets the slide's own background to a solid color, overriding whatever its layout/master would otherwise supply.
func (*Slide) BackgroundGradient ¶
func (s *Slide) BackgroundGradient(angleDegrees float64, stops ...GradientStop) *Slide
BackgroundGradient sets the slide's own background to a linear gradient — see ShapeRef.GradientFill for the angle convention, stop requirements, and error-accumulation behavior on an invalid angle or stop.
func (*Slide) BackgroundScheme ¶
func (s *Slide) BackgroundScheme(scheme SchemeColor) *Slide
BackgroundScheme sets the slide's own background to a theme color, referenced by scheme slot (e.g. SchemeAccent1) rather than an explicit RGB value.
func (*Slide) Body ¶
Body adds a body placeholder (type="body", idx=1 — matching the master's own body placeholder, so it inherits both geometry and the bulleted-list default from TxStyles.bodyStyle) with the given text. For a layout with more than one body placeholder (e.g. LayoutTwoContent), use AddPlaceholder(PlaceholderBody, idx) directly to pick idx 1 or 2.
func (*Slide) Connect ¶
func (s *Slide) Connect(from *ShapeRef, fromSite ConnSite, to *ShapeRef, toSite ConnSite, ct ConnectorType) *ConnectorRef
Connect adds a connector (p:cxnSp) whose start and end points are BOUND to connection sites on from and to (see ConnSite) — in PowerPoint's own UI, moving either shape re-routes the connector to follow, the behavior that distinguishes a real connector from a plain line shape (Slide.AddShape(ShapeLine, ...), which has no such binding). ct selects the connector's own routing geometry (e.g. ConnStraight, ConnBent — the default when ct is unset would be the zero value "", which is not a valid ST_ShapeType name, so callers must pass one explicitly).
The emitted a:xfrm spans the two connection POINTS the connector binds (not a bounding box of the two shapes' full rectangles — see connectorXfrm for why that distinction is load-bearing), computed from each endpoint's own spPr.Xfrm. A placeholder has no a:xfrm of its own (it inherits geometry from the layout — see AddPlaceholder), so Connect records an error on the presentation and leaves the connector unset when either endpoint is one; a shape added inside a Group is NOT such a case (Group.AddShape gives it a slide-absolute a:xfrm, so group members are connectable — the demo binds across a group boundary). PowerPoint recomputes the connector's actual visual routing from the binding once opened; the a:xfrm only needs to be non-degenerate, not an exact fit.
Both endpoints must be drawn with a preset in connSiteGeom (rect, roundRect, ellipse) — the geometries whose connection-site indices are verified (see ConnSite). An endpoint with any other preset, an unrecognized fromSite/toSite, or an invalid ct is recorded as an error on the presentation (returned by Save) and leaves the connector unset.
siteXY reads each endpoint's un-rotated cardinal point, so a connector to a shape that has been rotated (ShapeRef.Rotation) or flipped (FlipH/FlipV) may render slightly detached on first paint; because the stCxn/endCxn binding is still correct, PowerPoint re-routes it to the shape the moment that shape is nudged. Rotation-aware endpoints are a possible follow-up.
func (*Slide) DateText ¶
DateText places a date (or any short label) along the bottom-left of the slide, as a self-positioned dt placeholder. The text is literal — pptxgo writes exactly what you pass (deterministic, locale-independent) rather than an auto-updating date field. See Footer for the duplicate-call contract.
func (*Slide) Footer ¶
Footer places footer text along the bottom-center of the slide. It is a self-positioned ftr placeholder (with its own geometry, not inherited from the master), so it renders wherever the slide is shown. Calling Footer twice on one slide records an error (a duplicate placeholder), like AddPlaceholder.
func (*Slide) Notes ¶
Notes sets the slide's speaker notes to text — the note that appears in PowerPoint's notes pane and on the printed notes page. Embedded newlines ("\n") become line breaks within the note. Calling Notes again on the same slide appends the new text as a further paragraph rather than replacing it.
The first call across the whole presentation lazily creates the single notes master; a deck that never calls Notes emits no notes parts at all.
func (*Slide) SlideNumber ¶
SlideNumber places an auto-updating slide-number field along the bottom-right of the slide: a sldNum placeholder holding an a:fld the consumer resolves to the slide's current position (so it stays correct if slides are reordered). The literal fallback is the slide's position at generation time. See Footer for the duplicate-call contract.
func (*Slide) Title ¶
Title adds this slide's title placeholder with the given text and returns a handle for further formatting — a convenience shorthand for AddPlaceholder(<title type>, 0).AddParagraph().Text(text). The placeholder type depends on the slide's own layout (set via WithLayout): LayoutTitleSlide's title is type="ctrTitle" — the only type its layout declares — so Title uses that one; every other layout (including LayoutBlank) uses the ordinary type="title". Using the wrong type would still produce schema-valid XML, but the slide's own layout would have no same-typed placeholder to inherit the title's geometry from.
type SlideOption ¶
type SlideOption func(*slideConfig)
SlideOption configures a single slide at AddSlide time.
func WithLayout ¶
func WithLayout(layout LayoutType) SlideOption
WithLayout selects which of the presentation's standard layouts (see LayoutType) the new slide uses — e.g. LayoutTitleAndContent for a slide with a title and one body placeholder to fill via AddPlaceholder/Title/ Body. Omitting it (AddSlide with no options) keeps pptxgo's original default, LayoutBlank, so every existing AddSlide() call is unaffected.
type SpPr ¶
type SpPr struct {
XMLName xml.Name `xml:"p:spPr"`
Xfrm *drawingml.Xfrm `xml:"a:xfrm,omitempty"`
PrstGeom *drawingml.PrstGeom `xml:"a:prstGeom,omitempty"`
Fill *drawingml.SolidFill `xml:"a:solidFill,omitempty"`
Gradient *drawingml.GradFill `xml:"a:gradFill,omitempty"`
NoFill *drawingml.NoFill `xml:"a:noFill,omitempty"`
Ln *drawingml.Ln `xml:"a:ln,omitempty"`
EffectLst *drawingml.EffectLst `xml:"a:effectLst,omitempty"`
}
SpPr is p:spPr (CT_ShapeProperties): the shape's geometry and visual properties. A free text box needs an explicit a:xfrm — without one it has no position on the slide. Field order mirrors the schema: xfrm -> prstGeom -> (fill group) -> ln -> effectLst. This same struct is reused as-is for a p:pic's p:spPr (Fill, Gradient, and NoFill all stay nil there — a picture's fill is its blipFill, not a:solidFill/a:gradFill/ a:noFill). Fill, Gradient, and NoFill are the schema's EG_FillProperties choice: at most one should ever be set — the ShapeRef builder methods (Fill, FillScheme, GradientFill, NoFill) enforce that by clearing the others whenever one is set.
type SpTree ¶
type SpTree struct {
XMLName xml.Name `xml:"p:spTree"`
NvGrpSpPr *NvGrpSpPr `xml:"p:nvGrpSpPr"`
GrpSpPr *GrpSpPr `xml:"p:grpSpPr"`
Content []any `xml:",any"`
}
SpTree is p:spTree, the shape tree: the root container for every visible shape on a slide, layout, or master. Content is left as `any` — text boxes, pictures, and graphic frames are modeled by later phases; the walking skeleton only needs an empty, schema-valid tree.
func NewEmptySpTree ¶
func NewEmptySpTree() *SpTree
NewEmptySpTree returns a minimal, schema-valid shape tree with no shapes.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a handle onto a table placed via Slide.AddTable, for setting cell content and column/row sizing. ext is the enclosing p:graphicFrame's own extent (p:xfrm/a:ext), which ColumnWidth/RowHeight keep in sync with the table's actual total width/height — without that, resizing a column would change a:tblGrid but leave the frame's own bounding box stale. slidePath is the owning slide's part path, threaded down to each cell's Paragraph so Paragraph.Hyperlink (called from inside a table cell) scopes its relationship to the slide's own .rels, not the package root's — see ShapeRef.slidePath for the same requirement on shapes/text boxes.
func (*Table) Cell ¶
Cell returns a handle for setting the content of the cell at (row, col), both 0-indexed. Cell panics if row or col is out of range — the same contract a Go slice index gives, since a table's shape is fixed at AddTable and never grows.
func (*Table) ColumnWidth ¶
ColumnWidth sets the width of the given column, in EMUs (see the Inches/Points helpers), and recomputes the enclosing graphic frame's overall width (p:xfrm/a:ext/@cx) as the new sum of all column widths — AddTable splits the table's overall width evenly across columns to start, but the table's actual rendered width is always the sum of its column widths, and the frame's own extent must track that or the two disagree. An out-of-range col is recorded as an error on the presentation (returned by Save) and leaves the width unset, rather than panicking.
func (*Table) MergeCells ¶
MergeCells merges the rectangular region of cells from (fromRow, fromCol) to (toRow, toCol), inclusive, both 0-indexed. The encoding follows the convention real PowerPoint-authored files use (extracted from a python-pptx-generated table and confirmed against the OpenXML SDK validator, not hand-derived from the schema alone) — a schema-valid but wrong encoding passes validation yet gets silently "repaired" by PowerPoint on open:
- The region never loses a <a:tc>: every cell stays in its row so each row's cell count keeps matching a:tblGrid's column count, which PowerPoint treats as corrupt if it disagrees.
- The anchor (fromRow, fromCol) carries GridSpan/RowSpan (only set when greater than 1 — the schema's implicit default).
- A cell in the anchor's row but a later column also carries RowSpan (it heads its own column's vertical span within the region) plus HMerge.
- A cell in the anchor's column but a later row also carries GridSpan (it heads its own row's horizontal span within the region) plus VMerge.
- Every other (interior/corner) cell carries only HMerge and VMerge.
An out-of-range or inverted (from > to) region, or one overlapping a cell already part of another merge, is recorded as an error on the presentation (returned by Save) and leaves the table unchanged.
PowerPoint itself renders only the anchor cell's own content for a merged region — a non-anchor cell's txBody, even though the XML still carries it, never appears on the rendered slide. Populating a cell with Cell(...).Text(...) before merging it away is a natural call order (see examples/01_basic), so MergeCells transfers any non-anchor cell's existing paragraphs into the anchor (appended, in row-major order, after the anchor's own) rather than silently discarding them — the same mark-don't-delete principle the merge encoding itself follows.
Because that transfer APPENDS, and Cell(...).Text is itself AddParagraph().Text (also an append), re-labeling a merged region built from already-populated cells stacks the old and new paragraphs. To make a merged cell read as a single fresh label, either merge the cells while the region is still empty and set the anchor's text afterward (what examples/01_basic's Total row does), or populate only the anchor before merging.
func (*Table) RowHeight ¶
RowHeight sets the height of the given row, in EMUs, and recomputes the enclosing graphic frame's overall height (p:xfrm/a:ext/@cy) as the new sum of all row heights — see ColumnWidth for why the frame's extent must track the table's actual size. An out-of-range row is recorded as an error on the presentation (returned by Save) and leaves the height unset, rather than panicking.
type TableCell ¶
type TableCell struct {
// contains filtered or unexported fields
}
TableCell is a handle onto a single table cell (a:tc), returned by Table.Cell.
func (*TableCell) AddParagraph ¶
AddParagraph appends a new, empty paragraph to the cell and returns a handle for adding runs and formatting to it — the same Paragraph type Slide.AddTextBox uses, so bold, alignment, hyperlinks, and every other text-formatting method apply equally inside a table cell.
func (*TableCell) Anchor ¶
func (c *TableCell) Anchor(a VerticalAnchor) *TableCell
Anchor sets the cell's vertical text alignment within its own bounds (AnchorTop, AnchorMiddle, or AnchorBottom).
func (*TableCell) Border ¶
func (c *TableCell) Border(side TableCellSide, color drawingml.Color, widthPoints float64) *TableCell
Border sets one edge (or diagonal) of the cell's own outline to a solid color at the given width, in points — see ShapeRef.Border for the width's valid range. An out-of-range width is recorded as an error on the presentation (returned by Save) and leaves that side unset.
func (*TableCell) BorderScheme ¶
func (c *TableCell) BorderScheme(side TableCellSide, scheme SchemeColor, widthPoints float64) *TableCell
BorderScheme is Border's theme-color counterpart, referencing a scheme slot (e.g. SchemeAccent1) rather than an explicit RGB value.
func (*TableCell) Fill ¶
Fill sets the cell's background to a solid color, overriding the fill the table style would otherwise give it.
func (*TableCell) FillScheme ¶
func (c *TableCell) FillScheme(scheme SchemeColor) *TableCell
FillScheme sets the cell's background to a theme color, referenced by scheme slot (e.g. SchemeAccent1) rather than an explicit RGB value — so a branded table's cell fills follow WithTheme along with the rest of the deck.
type TableCellSide ¶
type TableCellSide string
TableCellSide names which edge (or diagonal) of a table cell TableCell.Border/BorderScheme sets an outline on (a:tcPr's six per-side line children).
const ( SideLeft TableCellSide = "l" SideRight TableCellSide = "r" SideTop TableCellSide = "t" SideBottom TableCellSide = "b" SideDiagonalDown TableCellSide = "tlToBr" // top-left to bottom-right SideDiagonalUp TableCellSide = "blToTr" // bottom-left to top-right )
The six CT_TableCellProperties line-child sides.
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template is a handle onto an existing .pptx opened via Open/ OpenFromBytes/OpenFromReader, for template-style editing: enumerating slides, inspecting or replacing their text, and saving the result back out.
Deliberately NOT a *Presentation: XMLPresentation and the other content- model structs (xml.go) cannot be unmarshaled from a foreign presentation.xml (see nav.go's own doc comment for why), so a rehydrated *Presentation would carry an empty/wrong pres field, and AddSlide (which mutates pres.SldIdLst directly) would then corrupt the file. Every part loaded through Open* instead stays as opaque Raw bytes inside the underlying opc.Package — Template only ever reads or byte-splices slide content (see substitute.go), never structurally edits the package.
func OpenFromBytes ¶
OpenFromBytes reads an existing .pptx already held in memory.
func OpenFromReader ¶
OpenFromReader reads an existing .pptx from r.
func (*Template) Merge ¶
func (t *Template) Merge(data MergeData, opts ...MergeOption) (int, error)
Merge substitutes every placeholder (default "{{key}}", see WithDelimiters) found across all slides with data[key], returning the number of placeholders substituted. With WithStrictMode, a placeholder with no matching key in data makes Merge return an error (the substitutions that DID match are still applied) instead of silently leaving unmatched placeholders in place.
func (*Template) PlaceholderNames ¶
func (t *Template) PlaceholderNames(opts ...MergeOption) ([]string, error)
PlaceholderNames returns the distinct placeholder names found anywhere across all slides, for inspecting what a template expects before calling Merge. Delimiters default to "{{"/"}}", the same as Merge; pass WithDelimiters here too if Merge will be called with a custom pair, so PlaceholderNames reports what Merge will actually match (WithStrictMode is accepted but has no effect — there is nothing to be strict about when only listing names).
Runs the SAME scan+run-grouping as Merge (via slideRunGroupTexts), NOT extractText: extractText concatenates every a:t in a paragraph regardless of formatting, so it would report a placeholder whose middle is separately formatted (e.g. "{{" and "}}" plain but the key bold — three runs with differing a:rPr that groupRuns keeps separate). Merge could never substitute such a placeholder (its regex runs per format group), so reporting it here would break the documented promise that PlaceholderNames lists exactly what Merge substitutes — and, worse, would make strict Merge look like it succeeded while the literal placeholder survived in the deck.
func (*Template) Replace ¶
Replace performs a literal (non-{{}}) substring replacement across every slide's text, returning the number of occurrences replaced. An empty old is rejected with an error: strings.ReplaceAll treats "" as matching between every character, so an empty old (e.g. from an unset variable) would otherwise inject new throughout every run and silently corrupt the whole deck. See substitute.go for how a match split across runs by PowerPoint's own editing history is healed before matching.
func (*Template) Save ¶
Save writes the presentation to w. Every part this Template never touched passes through verbatim (see opc.OpenBytes), so opening a template and saving it back out with no edits at all reproduces the original content, modulo Content_Types/.rels always being regenerated from in-memory state — semantically equivalent, not byte-identical, the same as any package this library assembles.
func (*Template) Slide ¶
Slide returns a handle onto the nth slide, 1-indexed — matching how a presentation's slides are numbered everywhere else (e.g. "slide 2").
func (*Template) SlideCount ¶
SlideCount returns the number of slides, in presentation order.
type TextBox ¶
type TextBox = ShapeRef
TextBox is a handle onto a text-box shape, returned by Slide.AddTextBox.
type TextStyle ¶
type TextStyle struct {
Levels []*LvlPPr
}
TextStyle wraps a cascading paragraph-level style definition, one LvlPPr per indentation level it defines (1-9; Paragraph.Level(0) through Level(8) select among them, 0-indexed there vs. 1-indexed in the OOXML element names). It deliberately has no XMLName field and instead implements MarshalXML: TxStyles reuses this one type for p:titleStyle, p:bodyStyle, and p:otherStyle (an XMLName field on the child would override the parent field's tag and force the same element name onto all three, the same reuse trap LvlPPr documents one level down), and each entry in Levels needs ITS OWN element name (a:lvl1pPr, a:lvl2pPr, ...) — something a single static field tag can't express either.
func (*TextStyle) MarshalXML ¶
MarshalXML emits start (whatever name the parent's own field tag gave this TextStyle — see the type doc) followed by each of Levels, each self-naming via LvlPPr.MarshalXML.
type Theme ¶
type Theme struct {
// Name is the theme's display name (a:theme/@name and the color/font
// scheme names). Empty defaults to "Office".
Name string
// Colors is the twelve-slot color scheme (a:clrScheme).
Colors ThemeColors
// Fonts is the major/minor font scheme (a:fontScheme).
Fonts ThemeFonts
}
Theme is a presentation's visual identity: the color scheme and font scheme (ppt/theme/theme1.xml's a:clrScheme and a:fontScheme) that every slide inherits. Pass one to New via WithTheme to brand a whole deck at once — because every shape/text/background can reference a theme color by slot (see SchemeColor, FillScheme, ColorScheme, BackgroundScheme) rather than a hardcoded RGB, swapping the Theme recolors all of them with no call-site changes.
Only the brand-relevant parts of a theme are modeled: the twelve color slots and the two font typefaces. The format scheme (a:fmtScheme — the fill/line/effect style *definitions* PowerPoint's own themes carry) is kept at Office's standard values, since a brand deck varies its palette and typography, not those low-level style-list definitions.
func DefaultTheme ¶
func DefaultTheme() Theme
DefaultTheme returns Office's standard theme — the palette and typography New uses when no WithTheme option is given. Start from it to tweak only a few slots:
t := pptx.DefaultTheme() t.Name = "Acme" t.Colors.Accent1 = pptx.RGB(0x1F, 0x49, 0x7D) p := pptx.New(pptx.WithTheme(t))
type ThemeColors ¶
type ThemeColors struct {
Dark1 drawingml.Color
Light1 drawingml.Color
Dark2 drawingml.Color
Light2 drawingml.Color
Accent1 drawingml.Color
Accent2 drawingml.Color
Accent3 drawingml.Color
Accent4 drawingml.Color
Accent5 drawingml.Color
Accent6 drawingml.Color
Hyperlink drawingml.Color
FollowedHyperlink drawingml.Color
}
ThemeColors is a theme's twelve-slot color scheme (a:clrScheme). Dark1/ Light1 are the primary text/background pair (conventionally near-black and near-white); Dark2/Light2 the secondary pair; Accent1-6 the accent palette; Hyperlink/FollowedHyperlink the two link colors. A slide references these through its color map (see NewDefaultClrMap) — e.g. SchemeAccent1 resolves to Accent1, SchemeText1/SchemeBackground1 to Dark1/Light1.
type ThemeFonts ¶
type ThemeFonts struct {
Major string // headings — a:majorFont's Latin typeface (e.g. "Calibri Light")
Minor string // body — a:minorFont's Latin typeface (e.g. "Calibri")
}
ThemeFonts is a theme's font scheme (a:fontScheme): the major (heading) and minor (body) Latin typefaces. Placeholder and default text with no explicit Font inherits the minor font; PowerPoint's own "+headings"/"+body" font choices resolve to these. An empty typeface defaults to Office's (Calibri Light major, Calibri minor).
type TxStyles ¶
type TxStyles struct {
XMLName xml.Name `xml:"p:txStyles"`
TitleStyle *TextStyle `xml:"p:titleStyle"`
BodyStyle *TextStyle `xml:"p:bodyStyle"`
OtherStyle *TextStyle `xml:"p:otherStyle"`
}
TxStyles is p:txStyles: default text formatting for title, body, and other placeholders, cascaded down to every layout and slide that doesn't override it. A single first-level definition per style is schema-valid; PowerPoint itself writes nine cascading levels, but nothing requires it.
func NewDefaultTxStyles ¶
func NewDefaultTxStyles() *TxStyles
NewDefaultTxStyles returns a minimal title/body/other text style set with conventional default sizes (44pt title, 32pt body, 18pt other). The body style carries a bullet default (alternating "•"/"–" in Arial) across all 9 levels so a body placeholder's paragraphs — at any Paragraph.Level(0..8) — pick up a bullet and indent automatically unless they set their own (Paragraph.Bullet/NumberedBullet) or explicitly suppress it (Paragraph.NoBullet) — pptxgo's txBody always emits its own a:lstStyle empty, so nothing on the placeholder itself overrides this cascade. TitleStyle/OtherStyle keep just their first level: pptxgo never applies a Level to a title or "other" placeholder's paragraphs, so levels 2-9 would go unused there.
type VerticalAnchor ¶
type VerticalAnchor string
VerticalAnchor is a text body's vertical anchoring within its shape (a:bodyPr's anchor attribute), for use with ShapeRef.Anchor.
const ( AnchorTop VerticalAnchor = "t" AnchorMiddle VerticalAnchor = "ctr" AnchorBottom VerticalAnchor = "b" )
Vertical anchor positions.
type XMLAppProperties ¶
type XMLAppProperties struct {
XMLName xml.Name `xml:"Properties"`
Xmlns string `xml:"xmlns,attr"`
Company string `xml:"Company,omitempty"`
Application string `xml:"Application,omitempty"`
}
XMLAppProperties represents docProps/app.xml (Properties, extended- properties namespace). CT_Properties is a strict xsd:sequence, so field order matters: Company precedes Application per the schema. Both children are optional.
func NewAppProperties ¶
func NewAppProperties() *XMLAppProperties
NewAppProperties returns docProps/app.xml content identifying pptxgo as the generating application, with no company. Kept for direct callers; see WithMetadata / WithCompany for the fuller path.
type XMLCoreProperties ¶
type XMLCoreProperties struct {
XMLName xml.Name `xml:"cp:coreProperties"`
XmlnsCP string `xml:"xmlns:cp,attr"`
XmlnsDC string `xml:"xmlns:dc,attr"`
XmlnsDCTerms string `xml:"xmlns:dcterms,attr"`
XmlnsXSI string `xml:"xmlns:xsi,attr"`
Title string `xml:"dc:title,omitempty"`
Subject string `xml:"dc:subject,omitempty"`
Creator string `xml:"dc:creator,omitempty"`
Keywords string `xml:"cp:keywords,omitempty"`
Description string `xml:"dc:description,omitempty"`
LastModifiedBy string `xml:"cp:lastModifiedBy,omitempty"`
Category string `xml:"cp:category,omitempty"`
Created *w3cdtf `xml:"dcterms:created,omitempty"`
Modified *w3cdtf `xml:"dcterms:modified,omitempty"`
}
XMLCoreProperties represents docProps/core.xml (cp:coreProperties). CT_CoreProperties is an xsd:all, so child order is unconstrained; every child is optional (omitempty). See NewCoreProperties / newCoreProperties.
func NewCoreProperties ¶
func NewCoreProperties(title, creator string) *XMLCoreProperties
NewCoreProperties returns docProps/core.xml content with the given title and creator (both optional; pass "" to omit). It is a thin convenience over the fuller Metadata path (see WithMetadata) kept for direct callers.
type XMLNotesMaster ¶
type XMLNotesMaster struct {
XMLName xml.Name `xml:"p:notesMaster"`
XmlnsA string `xml:"xmlns:a,attr"`
XmlnsR string `xml:"xmlns:r,attr"`
XmlnsP string `xml:"xmlns:p,attr"`
CSld *CSld `xml:"p:cSld"`
ClrMap *ClrMap `xml:"p:clrMap"`
}
XMLNotesMaster represents ppt/notesMasters/notesMaster1.xml (p:notesMaster): the single notes master every notes slide inherits from. pptxgo models a minimal one — a notes body placeholder and the standard color map — created lazily the first time any slide gets speaker notes.
type XMLNotesSlide ¶
type XMLNotesSlide struct {
XMLName xml.Name `xml:"p:notes"`
XmlnsA string `xml:"xmlns:a,attr"`
XmlnsR string `xml:"xmlns:r,attr"`
XmlnsP string `xml:"xmlns:p,attr"`
CSld *CSld `xml:"p:cSld"`
ClrMapOvr *ClrMapOvr `xml:"p:clrMapOvr"`
}
XMLNotesSlide represents a ppt/notesSlides/notesSlideN.xml part (p:notes): one slide's speaker notes, held in a body placeholder.
type XMLPresentation ¶
type XMLPresentation struct {
XMLName xml.Name `xml:"p:presentation"`
XmlnsA string `xml:"xmlns:a,attr"`
XmlnsR string `xml:"xmlns:r,attr"`
XmlnsP string `xml:"xmlns:p,attr"`
// Schema order (CT_Presentation): sldMasterIdLst, notesMasterIdLst,
// handoutMasterIdLst, sldIdLst, sldSz, notesSz. NotesMasterIdLst is nil
// until the first speaker note is added (see Slide.Notes), so a deck with
// no notes emits none.
SldMasterIdLst *SldMasterIdLst `xml:"p:sldMasterIdLst"`
NotesMasterIdLst *NotesMasterIdLst `xml:"p:notesMasterIdLst,omitempty"`
SldIdLst *SldIdLst `xml:"p:sldIdLst"`
SldSz *SldSz `xml:"p:sldSz"`
NotesSz *NotesSz `xml:"p:notesSz"`
}
XMLPresentation represents ppt/presentation.xml (p:presentation).
type XMLSlide ¶
type XMLSlide struct {
XMLName xml.Name `xml:"p:sld"`
XmlnsA string `xml:"xmlns:a,attr"`
XmlnsR string `xml:"xmlns:r,attr"`
XmlnsP string `xml:"xmlns:p,attr"`
CSld *CSld `xml:"p:cSld"`
ClrMapOvr *ClrMapOvr `xml:"p:clrMapOvr"`
}
XMLSlide represents a ppt/slides/slideN.xml part (p:sld).
type XMLSlideLayout ¶
type XMLSlideLayout struct {
XMLName xml.Name `xml:"p:sldLayout"`
XmlnsA string `xml:"xmlns:a,attr"`
XmlnsR string `xml:"xmlns:r,attr"`
XmlnsP string `xml:"xmlns:p,attr"`
Type string `xml:"type,attr,omitempty"`
CSld *CSld `xml:"p:cSld"`
ClrMapOvr *ClrMapOvr `xml:"p:clrMapOvr"`
}
XMLSlideLayout represents one ppt/slideLayouts/slideLayoutN.xml part (p:sldLayout) — see SlideLayoutPath and newStandardLayouts.
type XMLSlideMaster ¶
type XMLSlideMaster struct {
XMLName xml.Name `xml:"p:sldMaster"`
XmlnsA string `xml:"xmlns:a,attr"`
XmlnsR string `xml:"xmlns:r,attr"`
XmlnsP string `xml:"xmlns:p,attr"`
CSld *CSld `xml:"p:cSld"`
ClrMap *ClrMap `xml:"p:clrMap"`
SldLayoutIdLst *SldLayoutIdLst `xml:"p:sldLayoutIdLst"`
TxStyles *TxStyles `xml:"p:txStyles"`
}
XMLSlideMaster represents ppt/slideMasters/slideMaster1.xml (p:sldMaster).
The walking skeleton models this with structs rather than a hand-typed string literal (unlike the theme): cSld/spTree/clrMapOvr already exist as typed Go values because slide1.xml needs them, and CT_SlideMaster reuses those exact same schema types. Letting the XML encoder produce this part removes an entire class of "unclosed tag" or "mismatched attribute" risk that a hand-typed literal would carry, for no extra design cost. What stays genuinely deferred to a later phase is placeholder inheritance (p:ph, idx/type matching across master → layout → slide) — this phase's spTree has no shapes at all, just the required-empty group container.