pptx

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PPTX 相关的命名空间
	NsRelationships  = "http://schemas.openxmlformats.org/package/2006/relationships"
	NsPresentationML = "http://schemas.openxmlformats.org/presentationml/2006/main"
	NsDrawingML      = "http://schemas.openxmlformats.org/drawingml/2006/main"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Layout

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

Layout 表示幻灯片布局

type LinkType added in v0.0.4

type LinkType int

LinkType 定义超链接类型

const (
	LinkTypeExternal LinkType = iota // 外部链接
	LinkTypeSlide                    // 幻灯片内部链接
)

type Master

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

Master 表示母版

type Placeholder

type Placeholder struct {
	Type  PlaceholderType
	Name  string
	Index int
	Shape *etree.Element
	// contains filtered or unexported fields
}

Placeholder 表示幻灯片中的占位符

func (*Placeholder) Debug

func (p *Placeholder) Debug()

Debug 打印调试信息

func (*Placeholder) SetImage

func (p *Placeholder) SetImage(imagePath string) error

SetImage 设置占位符的图片,支持本地文件路径和网络URL

func (*Placeholder) SetTable

func (p *Placeholder) SetTable(data [][]string) error

SetTable 设置占位符的表格内容

func (*Placeholder) SetText

func (p *Placeholder) SetText(text string, options ...TextOption) error

SetText 设置占位符的文本内容,支持普通文本、LaTeX 公式和超链接

type PlaceholderType

type PlaceholderType int

PlaceholderType 定义占位符类型

const (
	PlaceholderTitle PlaceholderType = iota
	PlaceholderSubTile
	PlaceholderCrtTitle
	PlaceholderBody
	PlaceholderImage
	PlaceholderChart
	PlaceholderTable
	PlaceholderShape
	PlaceholderFooter
	PlaceholderHeader
	PlaceholderSlideNumber
	PlaceholderDate
)

type Presentation

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

Presentation 表示一个PPTX文件

func Open

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

Open 打开PPTX文件

func (*Presentation) AddSlide

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

AddSlide 添加新的幻灯片

func (*Presentation) Close

func (p *Presentation) Close() error

Close 关闭PPTX文件

func (*Presentation) DeleteSlide

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

DeleteSlide 删除指定索引的幻灯片

func (*Presentation) GetLayoutByName

func (p *Presentation) GetLayoutByName(name string) *Layout

GetLayoutByName 通过名称获取布局

func (*Presentation) GetMasterByName

func (p *Presentation) GetMasterByName(name string) *Master

GetMasterByName 通过名称获取母版

func (*Presentation) GetSlide

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

GetSlide 获取指定索引的幻灯片

func (*Presentation) GetSlides added in v0.0.2

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

func (*Presentation) Save

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

Save 保存PPTX文件

type Relationship added in v0.0.4

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

Relationship 定义了 PPTX 中的关系

type Slide

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

Slide 表示一个幻灯片

func (*Slide) GetPlaceholder

func (s *Slide) GetPlaceholder(params ...interface{}) (*Placeholder, error)

GetPlaceholder 通过类型、名称、索引或文本内容获取占位符

func (*Slide) GetPlaceholders

func (s *Slide) GetPlaceholders() ([]*Placeholder, error)

GetPlaceholders 获取幻灯片中所有占位符

func (*Slide) SaveChanges

func (s *Slide) SaveChanges() error

SaveChanges 保存对幻灯片的更改

type SlideSize

type SlideSize struct {
	Width  int
	Height int
	Type   string
}

SlideSize 表示幻灯片大小

type TextOption added in v0.0.4

type TextOption func(*TextOptions)

TextOption 定义文本设置的选项函数

func WithLatex added in v0.0.4

func WithLatex() TextOption

WithLatex 启用 LaTeX 支持

func WithLink(url string, linkType LinkType) TextOption

WithLink 添加超链接

type TextOptions added in v0.0.4

type TextOptions struct {
	EnableLatex bool
	Link        string   // 超链接URL
	LinkType    LinkType // 超链接类型
}

TextOptions 定义文本设置的选项

type TextSegment added in v0.0.3

type TextSegment struct {
	Text    string
	IsLatex bool
}

TextSegment 表示文本片段,可以是普通文本或LaTeX公式

Jump to

Keyboard shortcuts

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