gopresentation

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

README

goppt

A Go library for working with PowerPoint presentations. It handles reading, writing, and rendering .pptx files with no external dependencies.

Overview

goppt implements the OOXML specification used by PowerPoint 2007 and later. You can build presentations from scratch, parse existing files, and export slides to PNG images — all from pure Go code.

The slide renderer is designed to produce output that closely matches what PowerPoint itself generates. It handles the tricky parts: text layout, font metrics, CJK line-breaking rules, shape geometry, and chart drawing.

Getting Started

go get github.com/casibase/goppt

Requires Go 1.18 or later.

Building a Presentation

package main

import (
    "log"
    ppt "github.com/casibase/goppt"
)

func main() {
    p := ppt.New()
    p.GetDocumentProperties().Title = "Quarterly Review"
    p.GetDocumentProperties().Creator = "goppt"

    slide := p.GetActiveSlide()

    heading := slide.CreateRichTextShape()
    heading.SetOffsetX(500000).SetOffsetY(300000)
    heading.SetWidth(8000000).SetHeight(1000000)
    run := heading.CreateTextRun("Q3 Results")
    run.GetFont().SetSize(32).SetBold(true).SetColor(ppt.ColorBlue)

    body := slide.CreateRichTextShape()
    body.SetOffsetX(500000).SetOffsetY(1500000)
    body.SetWidth(8000000).SetHeight(600000)
    body.CreateTextRun("Revenue up 18% year over year")

    next := p.CreateSlide()
    chart := next.CreateChartShape()
    chart.BaseShape.SetOffsetX(500000).SetOffsetY(500000)
    chart.BaseShape.SetWidth(7000000).SetHeight(4500000)
    chart.GetTitle().SetText("Revenue by Quarter")

    bars := ppt.NewBarChart()
    bars.AddSeries(ppt.NewChartSeriesOrdered(
        "Revenue",
        []string{"Q1", "Q2", "Q3", "Q4"},
        []float64{120, 180, 150, 210},
    ))
    chart.GetPlotArea().SetType(bars)

    w, _ := ppt.NewWriter(p, ppt.WriterPowerPoint2007)
    if err := w.(*ppt.PPTXWriter).Save("review.pptx"); err != nil {
        log.Fatal(err)
    }
}

Reading an Existing File

reader := &ppt.PPTXReader{}
pres, err := reader.Read("existing.pptx")
if err != nil {
    log.Fatal(err)
}

for i, s := range pres.GetAllSlides() {
    fmt.Printf("slide %d — %d shapes\n", i+1, len(s.GetShapes()))
}

Writing to a Buffer

var buf bytes.Buffer
w, _ := ppt.NewWriter(p, ppt.WriterPowerPoint2007)
w.WriteTo(&buf)

Capabilities

Text and typography

  • Rich text runs with font family, size, color, bold, italic, underline, and strikethrough
  • Text boxes with auto-fit, auto-shrink, and overflow modes
  • Bullet lists (character and numeric)

Shapes

  • Auto shapes: rectangles, ellipses, triangles, arrows, stars, callouts, and more
  • Line shapes with configurable style and color
  • Group shapes and placeholder shapes

Images

  • Embed PNG, JPEG, GIF, BMP, or SVG from a file path or raw bytes
  • Rotation, flip, and group transform support

Charts

  • Bar, Bar3D, Line, Area, Pie, Pie3D, Doughnut, Scatter, Radar

Tables

  • Cell-level formatting, fills, and borders

Slide options

  • Solid and gradient backgrounds
  • Speaker notes
  • Comments with author metadata
  • Basic animation grouping
  • Document and custom properties
  • Slide sizes: 4:3, 16:9, 16:10, A4, Letter, or custom

Renderer

The built-in renderer exports slides to PNG. Key behaviors:

  • Uses two hinting modes (HintingNone for layout metrics, HintingFull for glyph rendering) to match PowerPoint's DirectWrite measurements
  • Implements kinsoku line-breaking rules for CJK text
  • Renders shape fills, strokes, drop shadows, and custom geometry paths
  • Draws all supported chart types with axes and series colors

Reference

See API.md for the complete API reference.

License

MIT

Documentation

Overview

Package gopresentation provides a pure Go library for reading and writing PowerPoint presentation files (.pptx) following the Office Open XML (OOXML) standard.

It is inspired by PHPOffice/PHPPresentation and provides an idiomatic Go API for creating, manipulating, and saving presentation documents.

See the Version variable for the current library version.

Index

Constants

View Source
const (
	NumFormatArabicPeriod  = "arabicPeriod"
	NumFormatArabicParen   = "arabicParenR"
	NumFormatRomanUcPeriod = "romanUcPeriod"
	NumFormatRomanLcPeriod = "romanLcPeriod"
	NumFormatAlphaUcPeriod = "alphaUcPeriod"
	NumFormatAlphaLcPeriod = "alphaLcPeriod"
	NumFormatAlphaLcParen  = "alphaLcParenR"
)

Numeric format constants.

View Source
const (
	ChartBlankAsGap  = "gap"
	ChartBlankAsZero = "zero"
	ChartBlankAsSpan = "span"
)

Chart display blank constants.

View Source
const (
	AxisCrossesAuto = "autoZero"
	AxisCrossesMin  = "min"
	AxisCrossesMax  = "max"
)

Axis crossing constants.

View Source
const (
	TickMarkNone    = "none"
	TickMarkInside  = "in"
	TickMarkOutside = "out"
	TickMarkCross   = "cross"
)

Tick mark constants.

View Source
const (
	TickLabelPosNextTo = "nextTo"
	TickLabelPosHigh   = "high"
	TickLabelPosLow    = "low"
)

Tick label position constants.

View Source
const (
	LabelInsideEnd  = "inEnd"
	LabelOutsideEnd = "outEnd"
	LabelCenter     = "ctr"
	LabelInsideBase = "inBase"
	LabelBestFit    = "bestFit"
)

Series label position constants.

View Source
const (
	MarkerCircle   = "circle"
	MarkerDash     = "dash"
	MarkerDiamond  = "diamond"
	MarkerDot      = "dot"
	MarkerPlus     = "plus"
	MarkerSquare   = "square"
	MarkerStar     = "star"
	MarkerTriangle = "triangle"
	MarkerX        = "x"
	MarkerNone     = "none"
)

Marker symbol constants.

View Source
const (
	BarGroupingClustered      = "clustered"
	BarGroupingStacked        = "stacked"
	BarGroupingPercentStacked = "percentStacked"
)

Bar grouping constants.

View Source
const (
	BarDirectionVertical   = "col"
	BarDirectionHorizontal = "bar"
)

Bar direction constants.

View Source
const (
	LayoutScreen4x3   = "screen4x3"
	LayoutScreen16x9  = "screen16x9"
	LayoutScreen16x10 = "screen16x10"
	LayoutA4          = "A4"
	LayoutLetter      = "letter"
	LayoutCustom      = "custom"
)

Standard layout constants (in EMU: 1 inch = 914400 EMU).

View Source
const (
	VersionMajor = 1
	VersionMinor = 0
	VersionPatch = 0
)

Version information for the GoPresentation library.

Variables

View Source
var (
	ColorBlack  = Color{ARGB: "FF000000"}
	ColorWhite  = Color{ARGB: "FFFFFFFF"}
	ColorRed    = Color{ARGB: "FFFF0000"}
	ColorGreen  = Color{ARGB: "FF00FF00"}
	ColorBlue   = Color{ARGB: "FF0000FF"}
	ColorYellow = Color{ARGB: "FFFFFF00"}
)

Predefined colors.

Version is the full version string of the GoPresentation library.

Functions

func Centimeter

func Centimeter(n float64) int64

Centimeter converts centimeters to EMU.

func DecodeEMFForTest

func DecodeEMFForTest(data []byte) image.Image

DecodeEMFForTest is an exported wrapper for testing EMF decoding.

func EMUToCentimeter

func EMUToCentimeter(emu int64) float64

EMUToCentimeter converts EMU to centimeters.

func EMUToInch

func EMUToInch(emu int64) float64

EMUToInch converts EMU to inches.

func EMUToMillimeter

func EMUToMillimeter(emu int64) float64

EMUToMillimeter converts EMU to millimeters.

func EMUToPoint

func EMUToPoint(emu int64) float64

EMUToPoint converts EMU to points.

func Inch

func Inch(n float64) int64

Inch converts inches to EMU. Clamps to safe range.

func Millimeter

func Millimeter(n float64) int64

Millimeter converts millimeters to EMU.

func Point

func Point(n float64) int64

Point converts points to EMU.

Types

type Alignment

type Alignment struct {
	Horizontal   HorizontalAlignment
	Vertical     VerticalAlignment
	MarginLeft   int64 // in EMU
	MarginRight  int64
	MarginTop    int64
	MarginBottom int64
	Indent       int64
	Level        int
}

Alignment represents text alignment properties.

func NewAlignment

func NewAlignment() *Alignment

NewAlignment creates a new Alignment with defaults.

func (*Alignment) SetHorizontal

func (a *Alignment) SetHorizontal(h HorizontalAlignment) *Alignment

SetHorizontal sets horizontal alignment.

func (*Alignment) SetVertical

func (a *Alignment) SetVertical(v VerticalAlignment) *Alignment

SetVertical sets vertical alignment.

type Animation

type Animation struct {
	ShapeIndexes []int // indexes of shapes in this animation group
}

Animation represents a slide animation.

func NewAnimation

func NewAnimation() *Animation

NewAnimation creates a new animation.

func (*Animation) AddShape

func (a *Animation) AddShape(index int) *Animation

AddShape adds a shape index to the animation.

func (*Animation) GetShapeIndexes

func (a *Animation) GetShapeIndexes() []int

GetShapeIndexes returns the shape indexes.

type AreaChart

type AreaChart struct {
	Series []*ChartSeries
}

AreaChart represents an area chart.

func NewAreaChart

func NewAreaChart() *AreaChart

NewAreaChart creates a new area chart.

func (*AreaChart) AddSeries

func (a *AreaChart) AddSeries(s *ChartSeries) *AreaChart

AddSeries adds a data series.

func (*AreaChart) GetChartTypeName

func (a *AreaChart) GetChartTypeName() string

type ArrowSize

type ArrowSize string

ArrowSize represents the size of an arrow head/tail.

const (
	ArrowSizeSm  ArrowSize = "sm"
	ArrowSizeMed ArrowSize = "med"
	ArrowSizeLg  ArrowSize = "lg"
)

type ArrowType

type ArrowType string

ArrowType represents the type of arrow head/tail on a line.

const (
	ArrowNone     ArrowType = "none"
	ArrowTriangle ArrowType = "triangle"
	ArrowStealth  ArrowType = "stealth"
	ArrowDiamond  ArrowType = "diamond"
	ArrowOval     ArrowType = "oval"
	ArrowArrow    ArrowType = "arrow"
)

type AutoFitType

type AutoFitType int

AutoFitType represents the auto-fit behavior.

const (
	AutoFitNone AutoFitType = iota
	AutoFitNormal
	AutoFitShape
)

type AutoShape

type AutoShape struct {
	BaseShape
	// contains filtered or unexported fields
}

AutoShape represents a predefined shape (rectangle, ellipse, etc.).

func NewAutoShape

func NewAutoShape() *AutoShape

NewAutoShape creates a new auto shape.

func (*AutoShape) GetAdjustValues

func (a *AutoShape) GetAdjustValues() map[string]int

func (*AutoShape) GetAutoShapeType

func (a *AutoShape) GetAutoShapeType() AutoShapeType

GetAutoShapeType returns the auto shape type.

func (*AutoShape) GetHeadEnd

func (a *AutoShape) GetHeadEnd() *LineEnd

GetAdjustValues returns the adjustment values map. GetHeadEnd returns the head end arrow.

func (*AutoShape) GetParagraphs

func (a *AutoShape) GetParagraphs() []*Paragraph

GetParagraphs returns the rich text paragraphs (if any).

func (*AutoShape) GetTailEnd

func (a *AutoShape) GetTailEnd() *LineEnd

GetTailEnd returns the tail end arrow.

func (*AutoShape) GetText

func (a *AutoShape) GetText() string

GetText returns the text content.

func (*AutoShape) GetType

func (a *AutoShape) GetType() ShapeType

func (*AutoShape) SetAutoShapeType

func (a *AutoShape) SetAutoShapeType(t AutoShapeType) *AutoShape

SetAutoShapeType sets the auto shape type.

func (*AutoShape) SetGeometry

func (a *AutoShape) SetGeometry(t AutoShapeType) *AutoShape

SetGeometry sets the shape geometry type (alias for SetAutoShapeType). This matches the unioffice naming convention.

func (*AutoShape) SetSolidFill

func (a *AutoShape) SetSolidFill(c Color) *AutoShape

SetSolidFill sets a solid fill on the auto shape.

func (*AutoShape) SetText

func (a *AutoShape) SetText(text string) *AutoShape

SetText sets the text content.

type AutoShapeType

type AutoShapeType string

AutoShapeType represents the type of auto shape.

const (
	AutoShapeRectangle            AutoShapeType = "rect"
	AutoShapeRoundedRect          AutoShapeType = "roundRect"
	AutoShapeEllipse              AutoShapeType = "ellipse"
	AutoShapeTriangle             AutoShapeType = "triangle"
	AutoShapeDiamond              AutoShapeType = "diamond"
	AutoShapeParallelogram        AutoShapeType = "parallelogram"
	AutoShapeTrapezoid            AutoShapeType = "trapezoid"
	AutoShapePentagon             AutoShapeType = "pentagon"
	AutoShapeHexagon              AutoShapeType = "hexagon"
	AutoShapeArrowRight           AutoShapeType = "rightArrow"
	AutoShapeArrowLeft            AutoShapeType = "leftArrow"
	AutoShapeArrowUp              AutoShapeType = "upArrow"
	AutoShapeArrowDown            AutoShapeType = "downArrow"
	AutoShapeStar4                AutoShapeType = "star4"
	AutoShapeStar5                AutoShapeType = "star5"
	AutoShapeStar10               AutoShapeType = "star10"
	AutoShapeStar12               AutoShapeType = "star12"
	AutoShapeStar16               AutoShapeType = "star16"
	AutoShapeStar24               AutoShapeType = "star24"
	AutoShapeStar32               AutoShapeType = "star32"
	AutoShapeHeart                AutoShapeType = "heart"
	AutoShapeLightningBolt        AutoShapeType = "lightningBolt"
	AutoShapeChevron              AutoShapeType = "chevron"
	AutoShapeCloud                AutoShapeType = "cloud"
	AutoShapePlus                 AutoShapeType = "mathPlus"
	AutoShapeMinus                AutoShapeType = "mathMinus"
	AutoShapeFlowchartProcess     AutoShapeType = "flowChartProcess"
	AutoShapeFlowchartDecision    AutoShapeType = "flowChartDecision"
	AutoShapeFlowchartPreparation AutoShapeType = "flowChartPreparation"
	AutoShapeCallout1             AutoShapeType = "wedgeRoundRectCallout"
	AutoShapeCallout2             AutoShapeType = "wedgeEllipseCallout"
	AutoShapeRibbon               AutoShapeType = "ribbon2"
	AutoShapeSmileyFace           AutoShapeType = "smileyFace"
	AutoShapeDonut                AutoShapeType = "donut"
	AutoShapeNoSmoking            AutoShapeType = "noSmoking"
	AutoShapeBlockArc             AutoShapeType = "blockArc"
	AutoShapeCube                 AutoShapeType = "cube"
	AutoShapeCan                  AutoShapeType = "can"
	AutoShapeBevel                AutoShapeType = "bevel"
	AutoShapeFoldedCorner         AutoShapeType = "foldedCorner"
	AutoShapeFrame                AutoShapeType = "frame"
	AutoShapePlaque               AutoShapeType = "plaque"
	AutoShapeLeftRightArrow       AutoShapeType = "leftRightArrow"
	AutoShapeRtTriangle           AutoShapeType = "rtTriangle"
	AutoShapeHomePlate            AutoShapeType = "homePlate"
	AutoShapeSnip2SameRect        AutoShapeType = "snip2SameRect"
	AutoShapePie                  AutoShapeType = "pie"
	AutoShapeArc                  AutoShapeType = "arc"
	AutoShapeBentArrow            AutoShapeType = "bentArrow"
	AutoShapeUturnArrow           AutoShapeType = "uturnArrow"
	AutoShapeMathEqual            AutoShapeType = "mathEqual"
	AutoShapeCurvedRightArrow     AutoShapeType = "curvedRightArrow"
	AutoShapeCurvedLeftArrow      AutoShapeType = "curvedLeftArrow"
	AutoShapeCurvedUpArrow        AutoShapeType = "curvedUpArrow"
	AutoShapeCurvedDownArrow      AutoShapeType = "curvedDownArrow"
)

type Bar3DChart

type Bar3DChart struct {
	BarChart
}

Bar3DChart represents a 3D bar chart.

func NewBar3DChart

func NewBar3DChart() *Bar3DChart

NewBar3DChart creates a new 3D bar chart.

func (*Bar3DChart) GetChartTypeName

func (b *Bar3DChart) GetChartTypeName() string

type BarChart

type BarChart struct {
	Series          []*ChartSeries
	BarGrouping     string
	BarDirection    string
	GapWidthPercent int
	OverlapPercent  int
}

BarChart represents a bar/column chart.

func NewBarChart

func NewBarChart() *BarChart

NewBarChart creates a new bar chart.

func (*BarChart) AddSeries

func (b *BarChart) AddSeries(s *ChartSeries) *BarChart

AddSeries adds a data series.

func (*BarChart) GetChartTypeName

func (b *BarChart) GetChartTypeName() string

func (*BarChart) SetBarGrouping

func (b *BarChart) SetBarGrouping(g string) *BarChart

SetBarGrouping sets the bar grouping type.

func (*BarChart) SetGapWidthPercent

func (b *BarChart) SetGapWidthPercent(v int) *BarChart

SetGapWidthPercent sets the gap width percentage (0-500).

func (*BarChart) SetOverlapPercent

func (b *BarChart) SetOverlapPercent(v int) *BarChart

SetOverlapPercent sets the overlap percentage (-100 to 100).

type BaseShape

type BaseShape struct {
	// contains filtered or unexported fields
}

BaseShape contains common shape properties.

func (*BaseShape) GetBorder

func (b *BaseShape) GetBorder() *Border

func (*BaseShape) GetDescription

func (b *BaseShape) GetDescription() string

func (*BaseShape) GetFill

func (b *BaseShape) GetFill() *Fill

func (*BaseShape) GetFlipHorizontal

func (b *BaseShape) GetFlipHorizontal() bool

GetFlipHorizontal returns whether the shape is flipped horizontally.

func (*BaseShape) GetFlipVertical

func (b *BaseShape) GetFlipVertical() bool

GetFlipVertical returns whether the shape is flipped vertically.

func (*BaseShape) GetHeight

func (b *BaseShape) GetHeight() int64
func (b *BaseShape) GetHyperlink() *Hyperlink

func (*BaseShape) GetName

func (b *BaseShape) GetName() string

func (*BaseShape) GetOffsetX

func (b *BaseShape) GetOffsetX() int64

func (*BaseShape) GetOffsetY

func (b *BaseShape) GetOffsetY() int64

func (*BaseShape) GetRotation

func (b *BaseShape) GetRotation() int

func (*BaseShape) GetShadow

func (b *BaseShape) GetShadow() *Shadow

func (*BaseShape) GetWidth

func (b *BaseShape) GetWidth() int64

func (*BaseShape) SetBorder

func (b *BaseShape) SetBorder(border *Border)

func (*BaseShape) SetDescription

func (b *BaseShape) SetDescription(d string)

func (*BaseShape) SetFill

func (b *BaseShape) SetFill(f *Fill)

func (*BaseShape) SetFlipHorizontal

func (b *BaseShape) SetFlipHorizontal(flip bool) *BaseShape

SetFlipHorizontal controls horizontal flipping.

func (*BaseShape) SetFlipVertical

func (b *BaseShape) SetFlipVertical(flip bool) *BaseShape

SetFlipVertical controls vertical flipping.

func (*BaseShape) SetHeight

func (b *BaseShape) SetHeight(h int64) *BaseShape
func (b *BaseShape) SetHyperlink(h *Hyperlink)

func (*BaseShape) SetName

func (b *BaseShape) SetName(n string) *BaseShape

func (*BaseShape) SetOffsetX

func (b *BaseShape) SetOffsetX(x int64) *BaseShape

func (*BaseShape) SetOffsetY

func (b *BaseShape) SetOffsetY(y int64) *BaseShape

func (*BaseShape) SetPosition

func (b *BaseShape) SetPosition(x, y int64) *BaseShape

SetPosition sets both offset X and Y in EMU.

func (*BaseShape) SetRotation

func (b *BaseShape) SetRotation(r int) *BaseShape

func (*BaseShape) SetShadow

func (b *BaseShape) SetShadow(s *Shadow)

func (*BaseShape) SetSize

func (b *BaseShape) SetSize(w, h int64) *BaseShape

SetSize sets both width and height in EMU.

func (*BaseShape) SetWidth

func (b *BaseShape) SetWidth(w int64) *BaseShape

type Border

type Border struct {
	Style BorderStyle
	Width int // in points (1 pt = 12700 EMU)
	Color Color
}

Border represents a shape border.

func NewBorder

func NewBorder() *Border

NewBorder creates a new Border with no border.

func (*Border) SetNoFill

func (b *Border) SetNoFill() *Border

SetNoFill removes the border.

func (*Border) SetSolidFill

func (b *Border) SetSolidFill(c Color) *Border

SetSolidFill sets a solid border with the given color.

func (*Border) SetWidth

func (b *Border) SetWidth(w int) *Border

SetWidth sets the border width in EMU.

type BorderStyle

type BorderStyle string

BorderStyle represents the border line style.

const (
	BorderNone  BorderStyle = "none"
	BorderSolid BorderStyle = "solid"
	BorderDash  BorderStyle = "dash"
	BorderDot   BorderStyle = "dot"
)

type BreakElement

type BreakElement struct{}

BreakElement represents a line break.

func (*BreakElement) GetElementType

func (br *BreakElement) GetElementType() string

type Bullet

type Bullet struct {
	Type      BulletType
	Style     string // character for BulletChar, e.g. "•", "–"
	Font      string // font name for BulletChar
	StartAt   int    // starting number for BulletNumeric
	NumFormat string // numeric format: "arabicPeriod", "romanUcPeriod", etc.
	Color     *Color
	Size      int // percentage of text size (25-400)
}

Bullet represents a paragraph bullet style.

func NewBullet

func NewBullet() *Bullet

NewBullet creates a new bullet with no bullet type.

func (*Bullet) SetCharBullet

func (b *Bullet) SetCharBullet(char string, font ...string) *Bullet

SetCharBullet sets a character bullet.

func (*Bullet) SetColor

func (b *Bullet) SetColor(c Color) *Bullet

SetColor sets the bullet color.

func (*Bullet) SetNumericBullet

func (b *Bullet) SetNumericBullet(format string, startAt ...int) *Bullet

SetNumericBullet sets a numeric bullet.

func (*Bullet) SetSize

func (b *Bullet) SetSize(pct int) *Bullet

SetSize sets the bullet size as percentage of text size.

type BulletType

type BulletType int

BulletType represents the type of bullet.

const (
	BulletTypeNone    BulletType = iota
	BulletTypeChar               // character bullet
	BulletTypeNumeric            // numbered bullet
	BulletTypeAutoNum            // auto-numbered
)

type CellBorders

type CellBorders struct {
	Top    *Border
	Bottom *Border
	Left   *Border
	Right  *Border
}

CellBorders represents borders for a table cell.

type ChartAxis

type ChartAxis struct {
	Title          string
	TitleRotation  int
	Visible        bool
	MinBounds      *float64
	MaxBounds      *float64
	MinorUnit      *float64
	MajorUnit      *float64
	CrossesAt      string
	ReversedOrder  bool
	Font           *Font
	MajorGridlines *Gridlines
	MinorGridlines *Gridlines
	MajorTickMark  string
	MinorTickMark  string
	TickLabelPos   string
	OutlineWidth   int
	OutlineColor   Color
}

ChartAxis represents a chart axis.

func NewChartAxis

func NewChartAxis() *ChartAxis

NewChartAxis creates a new chart axis.

func (*ChartAxis) ClearMaxBounds

func (a *ChartAxis) ClearMaxBounds() *ChartAxis

ClearMaxBounds clears the maximum bounds.

func (*ChartAxis) ClearMinBounds

func (a *ChartAxis) ClearMinBounds() *ChartAxis

ClearMinBounds clears the minimum bounds.

func (*ChartAxis) SetCrossesAt

func (a *ChartAxis) SetCrossesAt(v string) *ChartAxis

SetCrossesAt sets where the axis crosses.

func (*ChartAxis) SetMajorGridlines

func (a *ChartAxis) SetMajorGridlines(g *Gridlines) *ChartAxis

SetMajorGridlines sets the major gridlines.

func (*ChartAxis) SetMajorTickMark

func (a *ChartAxis) SetMajorTickMark(v string) *ChartAxis

SetMajorTickMark sets the major tick mark style.

func (*ChartAxis) SetMajorUnit

func (a *ChartAxis) SetMajorUnit(v float64) *ChartAxis

SetMajorUnit sets the major unit.

func (*ChartAxis) SetMaxBounds

func (a *ChartAxis) SetMaxBounds(v float64) *ChartAxis

SetMaxBounds sets the maximum bounds.

func (*ChartAxis) SetMinBounds

func (a *ChartAxis) SetMinBounds(v float64) *ChartAxis

SetMinBounds sets the minimum bounds.

func (*ChartAxis) SetMinorGridlines

func (a *ChartAxis) SetMinorGridlines(g *Gridlines) *ChartAxis

SetMinorGridlines sets the minor gridlines.

func (*ChartAxis) SetMinorTickMark

func (a *ChartAxis) SetMinorTickMark(v string) *ChartAxis

SetMinorTickMark sets the minor tick mark style.

func (*ChartAxis) SetMinorUnit

func (a *ChartAxis) SetMinorUnit(v float64) *ChartAxis

SetMinorUnit sets the minor unit.

func (*ChartAxis) SetReversedOrder

func (a *ChartAxis) SetReversedOrder(v bool) *ChartAxis

SetReversedOrder sets whether the axis is reversed.

func (*ChartAxis) SetTickLabelPosition

func (a *ChartAxis) SetTickLabelPosition(v string) *ChartAxis

SetTickLabelPosition sets the tick label position.

func (*ChartAxis) SetTitle

func (a *ChartAxis) SetTitle(title string) *ChartAxis

SetTitle sets the axis title.

func (*ChartAxis) SetTitleRotation

func (a *ChartAxis) SetTitleRotation(deg int) *ChartAxis

SetTitleRotation sets the axis title rotation in degrees.

func (*ChartAxis) SetVisible

func (a *ChartAxis) SetVisible(v bool) *ChartAxis

SetVisible sets axis visibility.

type ChartLegend

type ChartLegend struct {
	Visible  bool
	Position LegendPosition
	Font     *Font
}

ChartLegend represents a chart legend.

func NewChartLegend

func NewChartLegend() *ChartLegend

NewChartLegend creates a new chart legend.

type ChartSeries

type ChartSeries struct {
	Title            string
	Values           map[string]float64 // category -> value
	Categories       []string           // ordered category names
	FillColor        Color
	ShowCategoryName bool
	ShowLegendKey    bool
	ShowPercentage   bool
	ShowSeriesName   bool
	ShowValue        bool
	Separator        string
	LabelPosition    string
	Font             *Font
	Outline          *SeriesOutline
	Marker           *SeriesMarker
}

ChartSeries represents a data series in a chart.

func NewChartSeries

func NewChartSeries(title string, data map[string]float64) *ChartSeries

NewChartSeries creates a new chart series. Note: map iteration order is non-deterministic in Go, so category order may vary. Use NewChartSeriesOrdered for deterministic ordering.

func NewChartSeriesOrdered

func NewChartSeriesOrdered(title string, categories []string, values []float64) *ChartSeries

NewChartSeriesOrdered creates a series with ordered categories. If len(values) < len(categories), missing values default to 0. Extra values beyond len(categories) are ignored.

func (*ChartSeries) SetFillColor

func (s *ChartSeries) SetFillColor(c Color) *ChartSeries

SetFillColor sets the series fill color.

func (*ChartSeries) SetLabelPosition

func (s *ChartSeries) SetLabelPosition(pos string) *ChartSeries

SetLabelPosition sets the data label position.

type ChartShape

type ChartShape struct {
	BaseShape
	// contains filtered or unexported fields
}

ChartShape represents a chart embedded in a slide.

func NewChartShape

func NewChartShape() *ChartShape

NewChartShape creates a new chart shape.

func (*ChartShape) GetDisplayBlankAs

func (c *ChartShape) GetDisplayBlankAs() string

GetDisplayBlankAs returns how blank values are displayed.

func (*ChartShape) GetLegend

func (c *ChartShape) GetLegend() *ChartLegend

GetLegend returns the chart legend.

func (*ChartShape) GetPlotArea

func (c *ChartShape) GetPlotArea() *PlotArea

GetPlotArea returns the plot area.

func (*ChartShape) GetTitle

func (c *ChartShape) GetTitle() *ChartTitle

GetTitle returns the chart title.

func (*ChartShape) GetType

func (c *ChartShape) GetType() ShapeType

func (*ChartShape) GetView3D

func (c *ChartShape) GetView3D() *View3D

GetView3D returns the 3D view settings.

func (*ChartShape) SetDisplayBlankAs

func (c *ChartShape) SetDisplayBlankAs(mode string)

SetDisplayBlankAs sets how blank values are displayed.

type ChartTitle

type ChartTitle struct {
	Text    string
	Visible bool
	Font    *Font
}

ChartTitle represents a chart title.

func NewChartTitle

func NewChartTitle() *ChartTitle

NewChartTitle creates a new chart title.

func (*ChartTitle) SetText

func (ct *ChartTitle) SetText(text string) *ChartTitle

SetText sets the title text.

func (*ChartTitle) SetVisible

func (ct *ChartTitle) SetVisible(v bool) *ChartTitle

SetVisible sets the title visibility.

type ChartType

type ChartType interface {
	GetChartTypeName() string
}

ChartType is the interface for chart types.

type Color

type Color struct {
	ARGB string // 8-character hex string, e.g., "FF000000" for black
}

Color represents an ARGB color.

func NewColor

func NewColor(argb string) Color

NewColor creates a new Color from an ARGB hex string. Accepts 6-char RGB (e.g. "FF0000") or 8-char ARGB (e.g. "FFFF0000"). A leading "#" is stripped automatically.

func (Color) GetAlpha

func (c Color) GetAlpha() uint8

GetAlpha returns the alpha component (0-255).

func (Color) GetBlue

func (c Color) GetBlue() uint8

GetBlue returns the blue component (0-255).

func (Color) GetGreen

func (c Color) GetGreen() uint8

GetGreen returns the green component (0-255).

func (Color) GetRed

func (c Color) GetRed() uint8

GetRed returns the red component (0-255).

type Comment

type Comment struct {
	Author    *CommentAuthor
	Text      string
	Date      time.Time
	PositionX int // in 1/100th of a point
	PositionY int
}

Comment represents a slide comment.

func NewComment

func NewComment() *Comment

NewComment creates a new comment.

func (*Comment) SetAuthor

func (c *Comment) SetAuthor(a *CommentAuthor) *Comment

SetAuthor sets the comment author.

func (*Comment) SetDate

func (c *Comment) SetDate(d time.Time) *Comment

SetDate sets the comment date.

func (*Comment) SetPosition

func (c *Comment) SetPosition(x, y int) *Comment

SetPosition sets the comment position.

func (*Comment) SetText

func (c *Comment) SetText(text string) *Comment

SetText sets the comment text.

type CommentAuthor

type CommentAuthor struct {
	Name     string
	Initials string
	ID       int
	ColorIdx int
}

CommentAuthor represents a comment author.

func NewCommentAuthor

func NewCommentAuthor(name, initials string) *CommentAuthor

NewCommentAuthor creates a new comment author.

type CustomGeomPath

type CustomGeomPath struct {
	Width    int64         // path coordinate space width
	Height   int64         // path coordinate space height
	Commands []PathCommand // path commands (moveTo, lineTo, close, etc.)
}

CustomGeomPath represents a custom geometry path for freeform shapes.

type CustomProperty

type CustomProperty struct {
	Name  string
	Value interface{}
	Type  PropertyType
}

CustomProperty represents a custom document property.

type DocumentLayout

type DocumentLayout struct {
	CX   int64 // width in EMU (English Metric Units)
	CY   int64 // height in EMU
	Name string
}

DocumentLayout represents the slide dimensions.

func NewDocumentLayout

func NewDocumentLayout() *DocumentLayout

NewDocumentLayout creates a default 4:3 layout.

func (*DocumentLayout) SetCustomLayout

func (dl *DocumentLayout) SetCustomLayout(cx, cy int64)

SetCustomLayout sets custom dimensions in EMU. Both values must be positive.

func (*DocumentLayout) SetLayout

func (dl *DocumentLayout) SetLayout(name string)

SetLayout sets a predefined layout.

type DocumentProperties

type DocumentProperties struct {
	Creator        string
	LastModifiedBy string
	Created        time.Time
	Modified       time.Time
	Title          string
	Description    string
	Subject        string
	Keywords       string
	Category       string
	Company        string
	Status         string
	Revision       string
	// contains filtered or unexported fields
}

DocumentProperties holds standard and custom document properties.

func NewDocumentProperties

func NewDocumentProperties() *DocumentProperties

NewDocumentProperties creates new document properties with defaults.

func (*DocumentProperties) GetCustomProperties

func (dp *DocumentProperties) GetCustomProperties() []string

GetCustomProperties returns all custom property names.

func (*DocumentProperties) GetCustomPropertyType

func (dp *DocumentProperties) GetCustomPropertyType(name string) PropertyType

GetCustomPropertyType returns the type of a custom property.

func (*DocumentProperties) GetCustomPropertyValue

func (dp *DocumentProperties) GetCustomPropertyValue(name string) interface{}

GetCustomPropertyValue returns the value of a custom property.

func (*DocumentProperties) IsCustomPropertySet

func (dp *DocumentProperties) IsCustomPropertySet(name string) bool

IsCustomPropertySet checks if a custom property exists.

func (*DocumentProperties) SetCustomProperty

func (dp *DocumentProperties) SetCustomProperty(name string, value interface{}, propType PropertyType)

SetCustomProperty sets a custom property.

type DoughnutChart

type DoughnutChart struct {
	Series   []*ChartSeries
	HoleSize int // percentage 10-90
}

DoughnutChart represents a doughnut chart.

func NewDoughnutChart

func NewDoughnutChart() *DoughnutChart

NewDoughnutChart creates a new doughnut chart.

func (*DoughnutChart) AddSeries

func (d *DoughnutChart) AddSeries(s *ChartSeries) *DoughnutChart

AddSeries adds a data series.

func (*DoughnutChart) GetChartTypeName

func (d *DoughnutChart) GetChartTypeName() string

type DrawingShape

type DrawingShape struct {
	BaseShape
	// contains filtered or unexported fields
}

DrawingShape represents an image/drawing shape.

func NewDrawingShape

func NewDrawingShape() *DrawingShape

NewDrawingShape creates a new drawing shape.

func (*DrawingShape) GetAlphaValue

func (d *DrawingShape) GetAlphaValue() int

GetAlphaValue returns the alphaModFix amount (0-100000).

func (*DrawingShape) GetCropBottom

func (d *DrawingShape) GetCropBottom() int

GetCropBottom returns the bottom crop percentage (in 1/1000 of a percent).

func (*DrawingShape) GetCropLeft

func (d *DrawingShape) GetCropLeft() int

GetCropLeft returns the left crop percentage (in 1/1000 of a percent).

func (*DrawingShape) GetCropRight

func (d *DrawingShape) GetCropRight() int

GetCropRight returns the right crop percentage (in 1/1000 of a percent).

func (*DrawingShape) GetCropTop

func (d *DrawingShape) GetCropTop() int

GetCropTop returns the top crop percentage (in 1/1000 of a percent).

func (*DrawingShape) GetImageData

func (d *DrawingShape) GetImageData() []byte

GetImageData returns the raw image data.

func (*DrawingShape) GetMimeType

func (d *DrawingShape) GetMimeType() string

GetMimeType returns the image MIME type.

func (*DrawingShape) GetPath

func (d *DrawingShape) GetPath() string

GetPath returns the image file path.

func (*DrawingShape) GetType

func (d *DrawingShape) GetType() ShapeType

func (*DrawingShape) SetHeight

func (d *DrawingShape) SetHeight(h int64) *DrawingShape

SetHeight sets the height and returns for chaining.

func (*DrawingShape) SetImageData

func (d *DrawingShape) SetImageData(data []byte, mimeType string) *DrawingShape

SetImageData sets the raw image data.

func (*DrawingShape) SetImageFromFile

func (d *DrawingShape) SetImageFromFile(path string) error

SetImageFromFile loads an image from a file path and sets the data and MIME type. Returns an error if the file exceeds maxImageFileSize or cannot be read.

func (*DrawingShape) SetOffsetX

func (d *DrawingShape) SetOffsetX(x int64) *DrawingShape

SetOffsetX sets the X offset and returns for chaining.

func (*DrawingShape) SetOffsetY

func (d *DrawingShape) SetOffsetY(y int64) *DrawingShape

SetOffsetY sets the Y offset and returns for chaining.

func (*DrawingShape) SetPath

func (d *DrawingShape) SetPath(path string) *DrawingShape

SetPath sets the image file path.

func (*DrawingShape) SetWidth

func (d *DrawingShape) SetWidth(w int64) *DrawingShape

SetWidth sets the width and returns for chaining.

type Fill

type Fill struct {
	Type     FillType
	Color    Color
	EndColor Color // for gradient fills
	Rotation int   // gradient rotation in degrees
}

Fill represents a shape fill.

func NewFill

func NewFill() *Fill

NewFill creates a new Fill with no fill.

func (*Fill) SetGradientLinear

func (f *Fill) SetGradientLinear(startColor, endColor Color, rotation int) *Fill

SetGradientLinear sets a linear gradient fill. Rotation is normalized to 0–359.

func (*Fill) SetNoFill

func (f *Fill) SetNoFill() *Fill

SetNoFill clears the fill.

func (*Fill) SetSolid

func (f *Fill) SetSolid(color Color) *Fill

SetSolid sets a solid fill.

type FillType

type FillType int

FillType represents the type of fill.

const (
	FillNone FillType = iota
	FillSolid
	FillGradientLinear
	FillGradientPath
)

type Font

type Font struct {
	Name          string
	NameEA        string // East Asian font name (from <a:ea> element)
	Size          int    // in points
	Bold          bool
	Italic        bool
	Underline     UnderlineType
	Strikethrough bool
	Color         Color
	Superscript   bool
	Subscript     bool
}

Font represents text font properties.

func NewFont

func NewFont() *Font

NewFont creates a new Font with defaults.

func (*Font) SetBold

func (f *Font) SetBold(bold bool) *Font

SetBold sets the bold property and returns the font for chaining.

func (*Font) SetColor

func (f *Font) SetColor(color Color) *Font

SetColor sets the font color.

func (*Font) SetItalic

func (f *Font) SetItalic(italic bool) *Font

SetItalic sets the italic property.

func (*Font) SetName

func (f *Font) SetName(name string) *Font

SetName sets the font name.

func (*Font) SetSize

func (f *Font) SetSize(size int) *Font

SetSize sets the font size in points (clamped to 1–4000).

func (*Font) SetStrikethrough

func (f *Font) SetStrikethrough(s bool) *Font

SetStrikethrough sets the strikethrough property.

func (*Font) SetUnderline

func (f *Font) SetUnderline(u UnderlineType) *Font

SetUnderline sets the underline type.

type FontCache

type FontCache struct {
	// contains filtered or unexported fields
}

FontCache manages TrueType font loading and face caching. It searches system font directories and user-specified directories for .ttf and .otf files, then caches parsed fonts and rendered faces.

func NewFontCache

func NewFontCache(extraDirs ...string) *FontCache

NewFontCache creates a FontCache that searches the given directories plus the OS default font directories.

func (*FontCache) GetFace

func (fc *FontCache) GetFace(name string, sizePt float64, bold, italic bool) font.Face

GetFace returns a font.Face for the given font properties. It tries to find a matching TrueType font; returns nil if not found.

func (*FontCache) GetMeasureFace

func (fc *FontCache) GetMeasureFace(name string, sizePt float64, bold, italic bool) font.Face

GetMeasureFace returns a font.Face with HintingNone for text measurement. PowerPoint's text layout engine uses unhinted (ideal) glyph metrics for line wrapping and text measurement. Using HintingNone produces glyph advances that match PowerPoint's DirectWrite layout, so wrapping occurs at the same character positions.

func (*FontCache) LoadFont

func (fc *FontCache) LoadFont(name string, path string) error

LoadFont manually loads a TrueType/OpenType font file and registers it under the given name. Returns an error if the file exceeds maxFontFileSize.

func (*FontCache) LoadFontData

func (fc *FontCache) LoadFontData(name string, data []byte) error

LoadFontData registers a TrueType/OpenType font from raw bytes.

type Gridlines

type Gridlines struct {
	Width int
	Color Color
}

Gridlines represents chart gridlines.

func NewGridlines

func NewGridlines() *Gridlines

NewGridlines creates new gridlines.

type GroupShape

type GroupShape struct {
	BaseShape
	// contains filtered or unexported fields
}

GroupShape represents a group of shapes.

func NewGroupShape

func NewGroupShape() *GroupShape

NewGroupShape creates a new group shape.

func (*GroupShape) AddShape

func (g *GroupShape) AddShape(s Shape) *GroupShape

AddShape adds a shape to the group.

func (*GroupShape) GetGroupFill

func (g *GroupShape) GetGroupFill() *Fill

GetGroupFill returns the group-level fill (from grpSpPr), if any.

func (*GroupShape) GetShapeCount

func (g *GroupShape) GetShapeCount() int

GetShapeCount returns the number of shapes in the group.

func (*GroupShape) GetShapes

func (g *GroupShape) GetShapes() []Shape

GetShapes returns all shapes in the group.

func (*GroupShape) GetType

func (g *GroupShape) GetType() ShapeType

func (*GroupShape) RemoveShape

func (g *GroupShape) RemoveShape(index int) error

RemoveShape removes a shape by index.

type HorizontalAlignment

type HorizontalAlignment string

HorizontalAlignment represents horizontal text alignment.

const (
	HorizontalLeft        HorizontalAlignment = "l"
	HorizontalCenter      HorizontalAlignment = "ctr"
	HorizontalRight       HorizontalAlignment = "r"
	HorizontalJustify     HorizontalAlignment = "just"
	HorizontalDistributed HorizontalAlignment = "dist"
)
type Hyperlink struct {
	URL         string
	Tooltip     string
	IsInternal  bool
	SlideNumber int
}

Hyperlink represents a hyperlink.

func NewHyperlink(url string) *Hyperlink

NewHyperlink creates a new external hyperlink. The URL must use an allowed scheme (http, https, mailto, ftp, ftps). Returns nil if the URL scheme is not allowed.

func NewInternalHyperlink(slideNumber int) *Hyperlink

NewInternalHyperlink creates a hyperlink to another slide.

type ImageFormat

type ImageFormat int

ImageFormat represents the output image format.

const (
	ImageFormatPNG ImageFormat = iota
	ImageFormatJPEG
)

type LegendPosition

type LegendPosition string

LegendPosition represents the legend position.

const (
	LegendBottom   LegendPosition = "b"
	LegendTop      LegendPosition = "t"
	LegendLeft     LegendPosition = "l"
	LegendRight    LegendPosition = "r"
	LegendTopRight LegendPosition = "tr"
)

type LineChart

type LineChart struct {
	Series   []*ChartSeries
	IsSmooth bool
}

LineChart represents a line chart.

func NewLineChart

func NewLineChart() *LineChart

NewLineChart creates a new line chart.

func (*LineChart) AddSeries

func (l *LineChart) AddSeries(s *ChartSeries) *LineChart

AddSeries adds a data series.

func (*LineChart) GetChartTypeName

func (l *LineChart) GetChartTypeName() string

func (*LineChart) SetSmooth

func (l *LineChart) SetSmooth(v bool) *LineChart

SetSmooth sets whether the line is smooth.

type LineEnd

type LineEnd struct {
	Type   ArrowType
	Width  ArrowSize
	Length ArrowSize
}

LineEnd represents the arrow head or tail of a line.

type LineShape

type LineShape struct {
	BaseShape
	// contains filtered or unexported fields
}

LineShape represents a line shape.

func NewLineShape

func NewLineShape() *LineShape

NewLineShape creates a new line shape.

func (*LineShape) GetAdjustValues

func (l *LineShape) GetAdjustValues() map[string]int

GetAdjustValues returns the adjustment values for connector geometry.

func (*LineShape) GetConnectorType

func (l *LineShape) GetConnectorType() string

GetConnectorType returns the connector type (prstGeom value).

func (*LineShape) GetHeadEnd

func (l *LineShape) GetHeadEnd() *LineEnd

GetHeadEnd returns the head end.

func (*LineShape) GetLineColor

func (l *LineShape) GetLineColor() Color

GetLineColor returns the line color.

func (*LineShape) GetLineStyle

func (l *LineShape) GetLineStyle() BorderStyle

GetLineStyle returns the line style.

func (*LineShape) GetLineWidth

func (l *LineShape) GetLineWidth() int

GetLineWidth returns the line width.

func (*LineShape) GetLineWidthEMU

func (l *LineShape) GetLineWidthEMU() int

GetLineWidthEMU returns the line width in EMU for precise rendering. If the raw EMU value was not set, it falls back to lineWidth * 12700.

func (*LineShape) GetTailEnd

func (l *LineShape) GetTailEnd() *LineEnd

GetTailEnd returns the tail end.

func (*LineShape) GetType

func (l *LineShape) GetType() ShapeType

func (*LineShape) SetHeadEnd

func (l *LineShape) SetHeadEnd(e *LineEnd) *LineShape

SetHeadEnd sets the head end (arrow at start of line).

func (*LineShape) SetLineColor

func (l *LineShape) SetLineColor(c Color) *LineShape

SetLineColor sets the line color.

func (*LineShape) SetLineStyle

func (l *LineShape) SetLineStyle(s BorderStyle) *LineShape

SetLineStyle sets the line style.

func (*LineShape) SetLineWidth

func (l *LineShape) SetLineWidth(w int) *LineShape

SetLineWidth sets the line width.

func (*LineShape) SetTailEnd

func (l *LineShape) SetTailEnd(e *LineEnd) *LineShape

SetTailEnd sets the tail end (arrow at end of line).

type PPTXReader

type PPTXReader struct{}

PPTXReader reads PPTX files.

func (*PPTXReader) Read

func (r *PPTXReader) Read(path string) (*Presentation, error)

Read reads a presentation from a file path.

func (*PPTXReader) ReadFromReader

func (r *PPTXReader) ReadFromReader(reader io.ReaderAt, size int64) (*Presentation, error)

ReadFromReader reads a presentation from an io.ReaderAt.

type PPTXWriter

type PPTXWriter struct {
	// contains filtered or unexported fields
}

PPTXWriter writes presentations in PPTX format.

func (*PPTXWriter) Save

func (w *PPTXWriter) Save(path string) error

Save writes the presentation to a file.

func (*PPTXWriter) WriteTo

func (w *PPTXWriter) WriteTo(writer io.Writer) error

WriteTo writes the presentation to a writer.

type Paragraph

type Paragraph struct {
	// contains filtered or unexported fields
}

Paragraph represents a text paragraph.

func NewParagraph

func NewParagraph() *Paragraph

NewParagraph creates a new paragraph.

func (*Paragraph) CreateBreak

func (p *Paragraph) CreateBreak() *BreakElement

CreateBreak creates a line break element.

func (*Paragraph) CreateTextRun

func (p *Paragraph) CreateTextRun(text string) *TextRun

CreateTextRun creates a new text run.

func (*Paragraph) GetAlignment

func (p *Paragraph) GetAlignment() *Alignment

GetAlignment returns the paragraph alignment.

func (*Paragraph) GetBullet

func (p *Paragraph) GetBullet() *Bullet

GetBullet returns the paragraph bullet.

func (*Paragraph) GetElements

func (p *Paragraph) GetElements() []ParagraphElement

GetElements returns all paragraph elements.

func (*Paragraph) GetLineSpacing

func (p *Paragraph) GetLineSpacing() int

GetLineSpacing returns the line spacing.

func (*Paragraph) GetSpaceAfter

func (p *Paragraph) GetSpaceAfter() int

GetSpaceAfter returns the space after the paragraph.

func (*Paragraph) GetSpaceBefore

func (p *Paragraph) GetSpaceBefore() int

GetSpaceBefore returns the space before the paragraph.

func (*Paragraph) SetAlignment

func (p *Paragraph) SetAlignment(a *Alignment)

SetAlignment sets the paragraph alignment.

func (*Paragraph) SetBullet

func (p *Paragraph) SetBullet(b *Bullet)

SetBullet sets the paragraph bullet.

func (*Paragraph) SetLineSpacing

func (p *Paragraph) SetLineSpacing(spacing int)

SetLineSpacing sets the line spacing.

func (*Paragraph) SetSpaceAfter

func (p *Paragraph) SetSpaceAfter(v int)

SetSpaceAfter sets the space after the paragraph.

func (*Paragraph) SetSpaceBefore

func (p *Paragraph) SetSpaceBefore(v int)

SetSpaceBefore sets the space before the paragraph.

type ParagraphElement

type ParagraphElement interface {
	GetElementType() string
}

ParagraphElement is the interface for paragraph content.

type PathCommand

type PathCommand struct {
	Type string // "moveTo", "lnTo", "close", "cubicBezTo", "quadBezTo", "arcTo"
	Pts  []PathPoint
	// Arc parameters (only for arcTo): radii and angles in OOXML 60000ths of a degree
	WR, HR       int64 // ellipse radii in path coordinate units
	StAng, SwAng int64 // start angle and sweep angle (60000ths of a degree)
}

PathCommand represents a single path command.

type PathPoint

type PathPoint struct {
	X, Y int64
}

PathPoint represents a point in path coordinates.

type Pie3DChart

type Pie3DChart struct {
	PieChart
}

Pie3DChart represents a 3D pie chart.

func NewPie3DChart

func NewPie3DChart() *Pie3DChart

NewPie3DChart creates a new 3D pie chart.

func (*Pie3DChart) GetChartTypeName

func (p *Pie3DChart) GetChartTypeName() string

type PieChart

type PieChart struct {
	Series []*ChartSeries
}

PieChart represents a pie chart.

func NewPieChart

func NewPieChart() *PieChart

NewPieChart creates a new pie chart.

func (*PieChart) AddSeries

func (p *PieChart) AddSeries(s *ChartSeries) *PieChart

AddSeries adds a data series.

func (*PieChart) GetChartTypeName

func (p *PieChart) GetChartTypeName() string

type PlaceholderShape

type PlaceholderShape struct {
	RichTextShape
	// contains filtered or unexported fields
}

PlaceholderShape represents a placeholder shape (title, body, etc.).

func NewPlaceholderShape

func NewPlaceholderShape(phType PlaceholderType) *PlaceholderShape

NewPlaceholderShape creates a new placeholder shape.

func (*PlaceholderShape) Clear

func (p *PlaceholderShape) Clear()

Clear clears the placeholder content and adds a single empty paragraph. An empty paragraph is required by PowerPoint for the file to be valid.

func (*PlaceholderShape) ClearAll

func (p *PlaceholderShape) ClearAll()

ClearAll completely removes all paragraphs from the placeholder. You must add at least one paragraph via CreateParagraph before saving.

func (*PlaceholderShape) GetPlaceholderIndex

func (p *PlaceholderShape) GetPlaceholderIndex() int

GetPlaceholderIndex returns the placeholder index.

func (*PlaceholderShape) GetPlaceholderType

func (p *PlaceholderShape) GetPlaceholderType() PlaceholderType

GetPlaceholderType returns the placeholder type.

func (*PlaceholderShape) GetType

func (p *PlaceholderShape) GetType() ShapeType

func (*PlaceholderShape) Remove

func (p *PlaceholderShape) Remove(slide *Slide) bool

Remove removes this placeholder from the given slide. Returns true if the placeholder was found and removed.

func (*PlaceholderShape) SetPlaceholderIndex

func (p *PlaceholderShape) SetPlaceholderIndex(idx int)

SetPlaceholderIndex sets the placeholder index.

func (*PlaceholderShape) SetText

func (p *PlaceholderShape) SetText(text string)

SetText sets the placeholder text, replacing all existing content with a single paragraph.

type PlaceholderType

type PlaceholderType string

PlaceholderType represents the type of placeholder.

const (
	PlaceholderTitle    PlaceholderType = "title"
	PlaceholderBody     PlaceholderType = "body"
	PlaceholderCtrTitle PlaceholderType = "ctrTitle"
	PlaceholderSubTitle PlaceholderType = "subTitle"
	PlaceholderDate     PlaceholderType = "dt"
	PlaceholderFooter   PlaceholderType = "ftr"
	PlaceholderSlideNum PlaceholderType = "sldNum"
)

type PlotArea

type PlotArea struct {
	// contains filtered or unexported fields
}

PlotArea represents the chart plot area.

func NewPlotArea

func NewPlotArea() *PlotArea

NewPlotArea creates a new plot area.

func (*PlotArea) GetAxisX

func (pa *PlotArea) GetAxisX() *ChartAxis

GetAxisX returns the X axis.

func (*PlotArea) GetAxisY

func (pa *PlotArea) GetAxisY() *ChartAxis

GetAxisY returns the Y axis.

func (*PlotArea) GetType

func (pa *PlotArea) GetType() ChartType

GetType returns the chart type.

func (*PlotArea) SetType

func (pa *PlotArea) SetType(ct ChartType)

SetType sets the chart type.

type Presentation

type Presentation struct {
	// contains filtered or unexported fields
}

Presentation represents an in-memory PowerPoint presentation.

func New

func New() *Presentation

New creates a new Presentation with one default blank slide.

func Open

func Open(path string) (*Presentation, error)

Open reads a PPTX file from disk and returns a Presentation. This is a convenience wrapper around NewReader + Read.

func OpenTemplate

func OpenTemplate(path string) (*Presentation, error)

OpenTemplate opens a PPTX template file and returns a Presentation. Unlike Open, this removes all existing slides so you can add new ones using the template's layouts. The slide layouts and masters are preserved.

func ReadFrom

func ReadFrom(r io.ReaderAt, size int64) (*Presentation, error)

ReadFrom reads a PPTX from an io.ReaderAt with the given size.

func (*Presentation) AddDefaultSlideWithLayout

func (p *Presentation) AddDefaultSlideWithLayout(layoutName string) (*Slide, error)

AddDefaultSlideWithLayout creates a new slide with the given layout, similar to what PowerPoint does when inserting a slide with a layout. The slide starts empty with no placeholder content. This matches unioffice's AddDefaultSlideWithLayout behavior.

func (*Presentation) AddSlide

func (p *Presentation) AddSlide(slide *Slide) *Slide

AddSlide adds an existing slide to the presentation.

func (*Presentation) AddSlideWithLayout

func (p *Presentation) AddSlideWithLayout(layoutName string) (*Slide, error)

AddSlideWithLayout creates a new slide associated with the given layout name. The layout name is stored for reference but the slide starts empty.

func (*Presentation) Close

func (p *Presentation) Close() error

Close releases resources held by the presentation. It clears internal references to allow garbage collection.

func (*Presentation) CopySlide

func (p *Presentation) CopySlide(index int) (*Slide, error)

CopySlide creates a deep copy of the slide at the given index and appends it. Note: shapes are shallow-copied (reference types). Modify the returned slide's shapes independently by replacing them rather than mutating in place.

func (*Presentation) CreateSlide

func (p *Presentation) CreateSlide() *Slide

CreateSlide creates a new slide and adds it to the presentation.

func (*Presentation) CreateSlideMaster

func (p *Presentation) CreateSlideMaster() *SlideMaster

CreateSlideMaster creates a new slide master and adds it.

func (*Presentation) ExtractText

func (p *Presentation) ExtractText() string

ExtractText returns all text content from the presentation as a single string. Useful for search/indexing.

func (*Presentation) GetActiveSlide

func (p *Presentation) GetActiveSlide() *Slide

GetActiveSlide returns the currently active slide.

func (*Presentation) GetActiveSlideIndex

func (p *Presentation) GetActiveSlideIndex() int

GetActiveSlideIndex returns the active slide index.

func (*Presentation) GetAllSlides

func (p *Presentation) GetAllSlides() []*Slide

GetAllSlides returns all slides.

func (*Presentation) GetDocumentProperties

func (p *Presentation) GetDocumentProperties() *DocumentProperties

GetDocumentProperties returns the document properties.

func (*Presentation) GetLayout

func (p *Presentation) GetLayout() *DocumentLayout

GetLayout returns the document layout.

func (*Presentation) GetLayoutByName

func (p *Presentation) GetLayoutByName(name string) (*SlideLayout, error)

GetLayoutByName returns a SlideLayout by name from the first slide master. Returns an error if no layout with the given name is found.

func (*Presentation) GetPresentationProperties

func (p *Presentation) GetPresentationProperties() *PresentationProperties

GetPresentationProperties returns the presentation properties.

func (*Presentation) GetSlide

func (p *Presentation) GetSlide(index int) (*Slide, error)

GetSlide returns a slide by index.

func (*Presentation) GetSlideCount

func (p *Presentation) GetSlideCount() int

GetSlideCount returns the number of slides.

func (*Presentation) GetSlideLayouts

func (p *Presentation) GetSlideLayouts() []*SlideLayout

GetSlideLayouts returns all slide layouts from all slide masters.

func (*Presentation) GetSlideMasters

func (p *Presentation) GetSlideMasters() []*SlideMaster

GetSlideMasters returns all slide masters.

func (*Presentation) MoveSlide

func (p *Presentation) MoveSlide(fromIndex, toIndex int) error

MoveSlide moves a slide from one index to another.

func (*Presentation) RemoveSlideByIndex

func (p *Presentation) RemoveSlideByIndex(index int) error

RemoveSlideByIndex removes a slide by index. Returns an error if the index is out of range or if it would remove the last slide.

func (*Presentation) Save

func (p *Presentation) Save(path string) error

Save writes the presentation to a PPTX file. This is a convenience wrapper around NewWriter + Save.

func (*Presentation) SaveAsTemplate

func (p *Presentation) SaveAsTemplate(path string) error

SaveAsTemplate writes the presentation as a .potx template to a writer. The only difference from Save is the content type used.

func (*Presentation) SaveSlideAsImage

func (p *Presentation) SaveSlideAsImage(slideIndex int, path string, opts *RenderOptions) error

SaveSlideAsImage renders a slide and saves it to a file.

func (*Presentation) SaveSlidesAsImages

func (p *Presentation) SaveSlidesAsImages(pattern string, opts *RenderOptions) error

SaveSlidesAsImages renders all slides and saves them to files. The pattern should contain %d for the slide number (1-based), e.g. "slide_%d.png".

func (*Presentation) SaveToFile

func (p *Presentation) SaveToFile(path string) error

SaveToFile is an alias for Save for compatibility with unioffice naming.

func (*Presentation) SaveToFileAsTemplate

func (p *Presentation) SaveToFileAsTemplate(path string) error

SaveToFileAsTemplate is an alias for SaveAsTemplate.

func (*Presentation) SetActiveSlideIndex

func (p *Presentation) SetActiveSlideIndex(index int) error

SetActiveSlideIndex sets the active slide by index.

func (*Presentation) SetDocumentProperties

func (p *Presentation) SetDocumentProperties(props *DocumentProperties)

SetDocumentProperties sets the document properties.

func (*Presentation) SetLayout

func (p *Presentation) SetLayout(layout *DocumentLayout)

SetLayout sets the document layout.

func (*Presentation) SlideToImage

func (p *Presentation) SlideToImage(slideIndex int, opts *RenderOptions) (image.Image, error)

SlideToImage renders a single slide to an image.

func (*Presentation) Slides

func (p *Presentation) Slides() []*Slide

Slides returns all slides. This is an alias for GetAllSlides matching unioffice naming convention.

func (*Presentation) SlidesToImages

func (p *Presentation) SlidesToImages(opts *RenderOptions) ([]image.Image, error)

SlidesToImages renders all slides to images.

func (*Presentation) Validate

func (p *Presentation) Validate() error

Validate checks the presentation for structural issues and returns an error describing all problems found, or nil if the presentation is valid. This is analogous to unioffice's Validate() method.

func (*Presentation) WriteTo

func (p *Presentation) WriteTo(w io.Writer) error

WriteTo writes the presentation to a writer in PPTX format.

type PresentationProperties

type PresentationProperties struct {
	// contains filtered or unexported fields
}

PresentationProperties holds presentation-level properties.

func NewPresentationProperties

func NewPresentationProperties() *PresentationProperties

NewPresentationProperties creates new presentation properties with defaults.

func (*PresentationProperties) GetLastView

func (pp *PresentationProperties) GetLastView() ViewType

GetLastView returns the last view type.

func (*PresentationProperties) GetSlideshowType

func (pp *PresentationProperties) GetSlideshowType() SlideshowType

GetSlideshowType returns the slideshow type.

func (*PresentationProperties) GetThumbnailData

func (pp *PresentationProperties) GetThumbnailData() []byte

GetThumbnailData returns the thumbnail data.

func (*PresentationProperties) GetThumbnailPath

func (pp *PresentationProperties) GetThumbnailPath() string

GetThumbnailPath returns the thumbnail path.

func (*PresentationProperties) GetZoom

func (pp *PresentationProperties) GetZoom() float64

GetZoom returns the zoom level.

func (*PresentationProperties) IsCommentVisible

func (pp *PresentationProperties) IsCommentVisible() bool

IsCommentVisible returns whether comments are visible.

func (*PresentationProperties) IsMarkedAsFinal

func (pp *PresentationProperties) IsMarkedAsFinal() bool

IsMarkedAsFinal returns whether the presentation is marked as final.

func (*PresentationProperties) MarkAsFinal

func (pp *PresentationProperties) MarkAsFinal(final ...bool)

MarkAsFinal marks the presentation as final.

func (*PresentationProperties) SetCommentVisible

func (pp *PresentationProperties) SetCommentVisible(visible bool)

SetCommentVisible sets comment visibility.

func (*PresentationProperties) SetLastView

func (pp *PresentationProperties) SetLastView(view ViewType)

SetLastView sets the last view type.

func (*PresentationProperties) SetSlideshowType

func (pp *PresentationProperties) SetSlideshowType(t SlideshowType)

SetSlideshowType sets the slideshow type.

func (*PresentationProperties) SetThumbnailData

func (pp *PresentationProperties) SetThumbnailData(data []byte)

SetThumbnailData sets the thumbnail from raw data.

func (*PresentationProperties) SetThumbnailPath

func (pp *PresentationProperties) SetThumbnailPath(path string)

SetThumbnailPath sets the thumbnail from a file path.

func (*PresentationProperties) SetZoom

func (pp *PresentationProperties) SetZoom(zoom float64)

SetZoom sets the zoom level (clamped to 0.1–4.0).

type PropertyType

type PropertyType int

PropertyType represents the type of a custom property.

const (
	PropertyTypeString PropertyType = iota
	PropertyTypeBoolean
	PropertyTypeInteger
	PropertyTypeFloat
	PropertyTypeDate
	PropertyTypeUnknown
)

type RadarChart

type RadarChart struct {
	Series []*ChartSeries
}

RadarChart represents a radar chart.

func NewRadarChart

func NewRadarChart() *RadarChart

NewRadarChart creates a new radar chart.

func (*RadarChart) AddSeries

func (r *RadarChart) AddSeries(s *ChartSeries) *RadarChart

AddSeries adds a data series.

func (*RadarChart) GetChartTypeName

func (r *RadarChart) GetChartTypeName() string

type Reader

type Reader interface {
	Read(path string) (*Presentation, error)
	ReadFromReader(r io.ReaderAt, size int64) (*Presentation, error)
}

Reader is the interface for presentation readers.

func NewReader

func NewReader(format ReaderType) (Reader, error)

NewReader creates a reader for the given format.

type ReaderType

type ReaderType string

ReaderType represents the input format.

const (
	ReaderPowerPoint2007 ReaderType = "PowerPoint2007"
)

type RenderOptions

type RenderOptions struct {
	// Width is the output image width in pixels. Height is calculated from slide aspect ratio.
	// Default: 960
	Width int
	// Format is the output image format (PNG or JPEG).
	Format ImageFormat
	// JPEGQuality is the JPEG quality (1-100). Default: 90.
	JPEGQuality int
	// BackgroundColor overrides the slide background. Nil means use slide background or white.
	BackgroundColor *color.RGBA
	// DPI is the rendering DPI for font sizing. Default: 96.
	DPI float64
	// FontDirs specifies additional directories to search for TrueType/OpenType fonts.
	// System font directories are always searched automatically.
	FontDirs []string
	// FontCache allows sharing a pre-configured FontCache across multiple renders.
	// If nil, a new FontCache is created using FontDirs.
	FontCache *FontCache
	// OverlayOpacityScale scales the opacity of semi-transparent shape fills.
	// Value between 0.0 and 1.0. Default 0 means use 1.0 (no change).
	// Set to e.g. 0.5 to halve the opacity of overlays, making dark backgrounds brighter.
	OverlayOpacityScale float64
}

RenderOptions configures slide-to-image rendering.

func DefaultRenderOptions

func DefaultRenderOptions() *RenderOptions

DefaultRenderOptions returns default rendering options.

type RichTextShape

type RichTextShape struct {
	BaseShape
	// contains filtered or unexported fields
}

RichTextShape represents a rich text shape.

func NewRichTextShape

func NewRichTextShape() *RichTextShape

NewRichTextShape creates a new rich text shape.

func (*RichTextShape) CreateBreak

func (r *RichTextShape) CreateBreak() *BreakElement

CreateBreak creates a line break in the active paragraph.

func (*RichTextShape) CreateParagraph

func (r *RichTextShape) CreateParagraph() *Paragraph

CreateParagraph creates a new paragraph and makes it active.

func (*RichTextShape) CreateTextRun

func (r *RichTextShape) CreateTextRun(text string) *TextRun

CreateTextRun creates a text run in the active paragraph.

func (*RichTextShape) GetActiveParagraph

func (r *RichTextShape) GetActiveParagraph() *Paragraph

GetActiveParagraph returns the active paragraph.

func (*RichTextShape) GetAutoFit

func (r *RichTextShape) GetAutoFit() AutoFitType

GetAutoFit returns the auto-fit type.

func (*RichTextShape) GetColumns

func (r *RichTextShape) GetColumns() int

GetColumns returns the number of text columns.

func (*RichTextShape) GetCustomPath

func (r *RichTextShape) GetCustomPath() *CustomGeomPath

GetCustomPath returns the custom geometry path, if any.

func (*RichTextShape) GetParagraphs

func (r *RichTextShape) GetParagraphs() []*Paragraph

GetParagraphs returns all paragraphs.

func (*RichTextShape) GetTextAnchor

func (r *RichTextShape) GetTextAnchor() TextAnchorType

GetTextAnchor returns the text anchoring type.

func (*RichTextShape) GetType

func (r *RichTextShape) GetType() ShapeType

func (*RichTextShape) GetWordWrap

func (r *RichTextShape) GetWordWrap() bool

GetWordWrap returns word wrap setting.

func (*RichTextShape) SetAutoFit

func (r *RichTextShape) SetAutoFit(fit AutoFitType)

SetAutoFit sets the auto-fit type.

func (*RichTextShape) SetColumns

func (r *RichTextShape) SetColumns(cols int)

SetColumns sets the number of text columns.

func (*RichTextShape) SetHeight

func (r *RichTextShape) SetHeight(h int64) *RichTextShape

SetHeight sets the height and returns the shape for chaining.

func (*RichTextShape) SetOffsetX

func (r *RichTextShape) SetOffsetX(x int64) *RichTextShape

SetOffsetX sets the X offset and returns the shape for chaining.

func (*RichTextShape) SetOffsetY

func (r *RichTextShape) SetOffsetY(y int64) *RichTextShape

SetOffsetY sets the Y offset and returns the shape for chaining.

func (*RichTextShape) SetTextAnchor

func (r *RichTextShape) SetTextAnchor(anchor TextAnchorType)

SetTextAnchor sets the text anchoring type (vertical position of text within the shape).

func (*RichTextShape) SetWidth

func (r *RichTextShape) SetWidth(w int64) *RichTextShape

SetWidth sets the width and returns the shape for chaining.

func (*RichTextShape) SetWordWrap

func (r *RichTextShape) SetWordWrap(wrap bool)

SetWordWrap sets word wrap.

type ScatterChart

type ScatterChart struct {
	Series   []*ChartSeries
	IsSmooth bool
}

ScatterChart represents a scatter chart.

func NewScatterChart

func NewScatterChart() *ScatterChart

NewScatterChart creates a new scatter chart.

func (*ScatterChart) AddSeries

func (s *ScatterChart) AddSeries(series *ChartSeries) *ScatterChart

AddSeries adds a data series.

func (*ScatterChart) GetChartTypeName

func (s *ScatterChart) GetChartTypeName() string

func (*ScatterChart) SetSmooth

func (s *ScatterChart) SetSmooth(v bool) *ScatterChart

SetSmooth sets whether the line is smooth.

type SeriesMarker

type SeriesMarker struct {
	Symbol string
	Size   int
}

SeriesMarker represents a series marker.

type SeriesOutline

type SeriesOutline struct {
	Width int
	Color Color
}

SeriesOutline represents a series outline.

type Shadow

type Shadow struct {
	Visible    bool
	Direction  int // in degrees
	Distance   int // in points
	BlurRadius int
	Color      Color
	Alpha      int // 0-100
}

Shadow represents a shape shadow.

func NewShadow

func NewShadow() *Shadow

NewShadow creates a new Shadow.

func (*Shadow) SetDirection

func (s *Shadow) SetDirection(d int) *Shadow

SetDirection sets shadow direction in degrees (normalized to 0–359).

func (*Shadow) SetDistance

func (s *Shadow) SetDistance(d int) *Shadow

SetDistance sets shadow distance in points (clamped to >= 0).

func (*Shadow) SetVisible

func (s *Shadow) SetVisible(v bool) *Shadow

SetVisible sets shadow visibility.

type Shape

type Shape interface {
	GetType() ShapeType
	GetOffsetX() int64
	GetOffsetY() int64
	GetWidth() int64
	GetHeight() int64
	GetName() string
	GetRotation() int
	// contains filtered or unexported methods
}

Shape is the interface that all shapes implement.

type ShapeType

type ShapeType int

ShapeType represents the type of shape.

const (
	ShapeTypeRichText ShapeType = iota
	ShapeTypeDrawing
	ShapeTypeTable
	ShapeTypeAutoShape
	ShapeTypeLine
	ShapeTypeChart
)
const ShapeTypeGroup ShapeType = 10

ShapeTypeGroup is the shape type for groups.

const ShapeTypePlaceholder ShapeType = 11

ShapeTypePlaceholder is the shape type for placeholders.

type Slide

type Slide struct {
	// contains filtered or unexported fields
}

Slide represents a single slide in a presentation.

func (*Slide) AddAnimation

func (s *Slide) AddAnimation(a *Animation)

AddAnimation adds an animation to the slide.

func (*Slide) AddAutoShape

func (s *Slide) AddAutoShape() *AutoShape

AddAutoShape creates a new auto shape and adds it to the slide. This matches unioffice's Slide.AddShape pattern.

func (*Slide) AddComment

func (s *Slide) AddComment(c *Comment)

AddComment adds a comment to the slide.

func (*Slide) AddImage

func (s *Slide) AddImage(path string) (*DrawingShape, error)

AddImage creates a drawing shape from a file path and adds it to the slide. This is a convenience method matching unioffice's Slide.AddImage pattern.

func (*Slide) AddImageData

func (s *Slide) AddImageData(data []byte, mimeType string) *DrawingShape

AddImageData creates a drawing shape from raw image data and adds it to the slide.

func (*Slide) AddShape

func (s *Slide) AddShape(shape Shape)

AddShape adds a shape to the slide.

func (*Slide) AddTable

func (s *Slide) AddTable(rows, cols int) *TableShape

AddTable creates a new table shape and adds it to the slide. This matches unioffice's Slide.AddTable pattern.

func (*Slide) AddTextBox

func (s *Slide) AddTextBox() *RichTextShape

AddTextBox creates a new rich text shape and adds it to the slide. This is an alias for CreateRichTextShape matching unioffice naming.

func (*Slide) CreateAutoShape

func (s *Slide) CreateAutoShape() *AutoShape

CreateAutoShape creates a new auto shape and adds it to the slide.

func (*Slide) CreateChartShape

func (s *Slide) CreateChartShape() *ChartShape

CreateChartShape creates a new chart shape and adds it to the slide.

func (*Slide) CreateDrawingShape

func (s *Slide) CreateDrawingShape() *DrawingShape

CreateDrawingShape creates a new drawing (image) shape and adds it to the slide.

func (*Slide) CreateGroupShape

func (s *Slide) CreateGroupShape() *GroupShape

CreateGroupShape creates a new group shape and adds it to the slide.

func (*Slide) CreateLineShape

func (s *Slide) CreateLineShape() *LineShape

CreateLineShape creates a new line shape and adds it to the slide.

func (*Slide) CreatePlaceholderShape

func (s *Slide) CreatePlaceholderShape(phType PlaceholderType) *PlaceholderShape

CreatePlaceholderShape creates a new placeholder shape and adds it to the slide.

func (*Slide) CreateRichTextShape

func (s *Slide) CreateRichTextShape() *RichTextShape

CreateRichTextShape creates a new rich text shape and adds it to the slide.

func (*Slide) CreateTableShape

func (s *Slide) CreateTableShape(rows, cols int) *TableShape

CreateTableShape creates a new table shape and adds it to the slide.

func (*Slide) ExtractText

func (s *Slide) ExtractText() string

ExtractText returns all text content from this slide as a single string.

func (*Slide) GetAnimations

func (s *Slide) GetAnimations() []*Animation

GetAnimations returns all animations on the slide.

func (*Slide) GetBackground

func (s *Slide) GetBackground() *Fill

GetBackground returns the slide background fill.

func (*Slide) GetCommentCount

func (s *Slide) GetCommentCount() int

GetCommentCount returns the number of comments.

func (*Slide) GetComments

func (s *Slide) GetComments() []*Comment

GetComments returns all comments on the slide.

func (*Slide) GetName

func (s *Slide) GetName() string

GetName returns the slide name.

func (*Slide) GetNotes

func (s *Slide) GetNotes() string

GetNotes returns the slide notes.

func (*Slide) GetPlaceholder

func (s *Slide) GetPlaceholder(phType PlaceholderType) *PlaceholderShape

GetPlaceholder returns the first placeholder of the given type. Returns nil if no placeholder of that type exists.

func (*Slide) GetPlaceholderByIndex

func (s *Slide) GetPlaceholderByIndex(idx int) *PlaceholderShape

GetPlaceholderByIndex returns a placeholder by its index. Returns nil if no placeholder with that index exists.

func (*Slide) GetPlaceholders

func (s *Slide) GetPlaceholders() []*PlaceholderShape

GetPlaceholders returns all placeholder shapes on the slide.

func (*Slide) GetShapeCount

func (s *Slide) GetShapeCount() int

GetShapeCount returns the number of shapes on the slide.

func (*Slide) GetShapes

func (s *Slide) GetShapes() []Shape

GetShapes returns all shapes on the slide.

func (*Slide) GetTextBoxes

func (s *Slide) GetTextBoxes() []*RichTextShape

GetTextBoxes returns all RichTextShape (text box) shapes on the slide.

func (*Slide) GetTransition

func (s *Slide) GetTransition() *Transition

GetTransition returns the slide transition.

func (*Slide) IsVisible

func (s *Slide) IsVisible() bool

IsVisible returns whether the slide is visible.

func (*Slide) RemoveShape

func (s *Slide) RemoveShape(index int) error

RemoveShape removes a shape by index.

func (*Slide) RemoveShapeByPointer

func (s *Slide) RemoveShapeByPointer(target Shape) bool

RemoveShapeByPointer removes a specific shape from the slide.

func (*Slide) SetBackground

func (s *Slide) SetBackground(f *Fill)

SetBackground sets the slide background fill.

func (*Slide) SetName

func (s *Slide) SetName(name string)

SetName sets the slide name.

func (*Slide) SetNotes

func (s *Slide) SetNotes(notes string)

SetNotes sets the slide notes.

func (*Slide) SetTransition

func (s *Slide) SetTransition(t *Transition)

SetTransition sets the slide transition.

func (*Slide) SetVisible

func (s *Slide) SetVisible(visible bool)

SetVisible sets the slide visibility.

type SlideLayout

type SlideLayout struct {
	Name string
	Type string
}

SlideLayout represents a slide layout.

type SlideMaster

type SlideMaster struct {
	Name         string
	SlideLayouts []*SlideLayout
}

SlideMaster represents a slide master.

type SlideshowType

type SlideshowType int

SlideshowType represents the slideshow type.

const (
	SlideshowTypePresent SlideshowType = iota
	SlideshowTypeBrowse
	SlideshowTypeKiosk
)

type TableCell

type TableCell struct {
	// contains filtered or unexported fields
}

TableCell represents a table cell.

func NewTableCell

func NewTableCell() *TableCell

NewTableCell creates a new table cell.

func (*TableCell) GetBorders

func (tc *TableCell) GetBorders() *CellBorders

GetBorders returns the cell borders.

func (*TableCell) GetColSpan

func (tc *TableCell) GetColSpan() int

GetColSpan returns the column span.

func (*TableCell) GetFill

func (tc *TableCell) GetFill() *Fill

GetFill returns the cell fill.

func (*TableCell) GetParagraphs

func (tc *TableCell) GetParagraphs() []*Paragraph

GetParagraphs returns the cell paragraphs.

func (*TableCell) GetRowSpan

func (tc *TableCell) GetRowSpan() int

GetRowSpan returns the row span.

func (*TableCell) SetColSpan

func (tc *TableCell) SetColSpan(span int)

SetColSpan sets the column span.

func (*TableCell) SetFill

func (tc *TableCell) SetFill(f *Fill)

SetFill sets the cell fill.

func (*TableCell) SetRowSpan

func (tc *TableCell) SetRowSpan(span int)

SetRowSpan sets the row span.

func (*TableCell) SetText

func (tc *TableCell) SetText(text string) *TableCell

SetText sets the cell text (convenience method).

type TableShape

type TableShape struct {
	BaseShape
	// contains filtered or unexported fields
}

TableShape represents a table shape.

func NewTableShape

func NewTableShape(rows, cols int) *TableShape

NewTableShape creates a new table shape.

func (*TableShape) GetCell

func (t *TableShape) GetCell(row, col int) *TableCell

GetCell returns a cell at the given row and column.

func (*TableShape) GetNumCols

func (t *TableShape) GetNumCols() int

GetNumCols returns the number of columns.

func (*TableShape) GetNumRows

func (t *TableShape) GetNumRows() int

GetNumRows returns the number of rows.

func (*TableShape) GetRows

func (t *TableShape) GetRows() [][]*TableCell

GetRows returns all rows.

func (*TableShape) GetType

func (t *TableShape) GetType() ShapeType

func (*TableShape) SetHeight

func (t *TableShape) SetHeight(h int64) *TableShape

SetHeight sets the height and returns for chaining.

func (*TableShape) SetWidth

func (t *TableShape) SetWidth(w int64) *TableShape

SetWidth sets the width and returns for chaining.

type TextAnchorType

type TextAnchorType string

TextAnchorType represents the text anchoring type within a shape.

const (
	TextAnchorTop    TextAnchorType = "t"
	TextAnchorMiddle TextAnchorType = "ctr"
	TextAnchorBottom TextAnchorType = "b"
	TextAnchorNone   TextAnchorType = ""
)

type TextRun

type TextRun struct {
	// contains filtered or unexported fields
}

TextRun represents a run of text with formatting.

func (*TextRun) GetElementType

func (tr *TextRun) GetElementType() string

func (*TextRun) GetFont

func (tr *TextRun) GetFont() *Font

GetFont returns the font properties.

func (tr *TextRun) GetHyperlink() *Hyperlink

GetHyperlink returns the hyperlink.

func (*TextRun) GetText

func (tr *TextRun) GetText() string

GetText returns the text content.

func (*TextRun) SetFont

func (tr *TextRun) SetFont(f *Font)

SetFont sets the font properties.

func (tr *TextRun) SetHyperlink(h *Hyperlink)

SetHyperlink sets the hyperlink.

func (*TextRun) SetText

func (tr *TextRun) SetText(text string)

SetText sets the text content.

type Transition

type Transition struct {
	Type     TransitionType
	Speed    TransitionSpeed
	Duration int // in milliseconds
}

Transition represents a slide transition.

type TransitionSpeed

type TransitionSpeed string

TransitionSpeed represents the speed of a transition.

const (
	TransitionSpeedSlow   TransitionSpeed = "slow"
	TransitionSpeedMedium TransitionSpeed = "med"
	TransitionSpeedFast   TransitionSpeed = "fast"
)

type TransitionType

type TransitionType int

TransitionType represents the type of slide transition.

const (
	TransitionNone TransitionType = iota
	TransitionFade
	TransitionPush
	TransitionWipe
	TransitionSplit
	TransitionCover
	TransitionUncover
	TransitionDissolve
)

type UnderlineType

type UnderlineType string

UnderlineType represents the underline style.

const (
	UnderlineNone   UnderlineType = "none"
	UnderlineSingle UnderlineType = "sng"
	UnderlineDouble UnderlineType = "dbl"
	UnderlineHeavy  UnderlineType = "heavy"
	UnderlineDash   UnderlineType = "dash"
	UnderlineWavy   UnderlineType = "wavy"
)

type VerticalAlignment

type VerticalAlignment string

VerticalAlignment represents vertical text alignment.

const (
	VerticalTop    VerticalAlignment = "t"
	VerticalMiddle VerticalAlignment = "ctr"
	VerticalBottom VerticalAlignment = "b"
)

type View3D

type View3D struct {
	RotX           int
	RotY           int
	DepthPercent   int
	HeightPercent  *int
	RightAngleAxes bool
}

View3D represents 3D view settings.

func NewView3D

func NewView3D() *View3D

NewView3D creates new 3D view settings.

func (*View3D) SetHeightPercent

func (v *View3D) SetHeightPercent(hp *int)

SetHeightPercent sets the height percent. Pass nil to enable autoscale.

type ViewType

type ViewType int

ViewType represents the last view type.

const (
	ViewSlide ViewType = iota
	ViewNotes
	ViewHandout
	ViewOutline
	ViewSlideMaster
	ViewSlideSorter
)

type Writer

type Writer interface {
	Save(path string) error
	WriteTo(w io.Writer) error
}

Writer is the interface for presentation writers.

func NewWriter

func NewWriter(p *Presentation, format WriterType) (Writer, error)

NewWriter creates a writer for the given format.

type WriterType

type WriterType string

WriterType represents the output format.

const (
	WriterPowerPoint2007 WriterType = "PowerPoint2007"
)

Directories

Path Synopsis
cmd
render_all command
render_slide40 command
render_slide7 command
render_test2 command

Jump to

Keyboard shortcuts

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