Documentation
¶
Index ¶
- Constants
- func ParsePPT(filePath string) (map[string][]types.File, error)
- type AnimationContent
- type AudioContent
- type ChartContent
- type CommentContent
- type ContentTypeMap
- type ImageContent
- type MacroContent
- type MasterSlideContent
- type NoteContent
- type OpcPackage
- type PPTClassifier
- type PPTNode
- type PPTXParser
- type PackURI
- type PackageLoader
- type Part
- func (p *Part) Blob() []byte
- func (p *Part) ContentType() string
- func (p *Part) LoadRelsFromXML(xml []byte, parts map[PackURI]*Part) error
- func (p *Part) Package() *OpcPackage
- func (p *Part) PartRelatedBy(relType RelationshipType) (*Part, error)
- func (p *Part) Partname() PackURI
- func (p *Part) RelatedPart(rID string) (*Part, error)
- func (p *Part) Rels() *Relationships
- func (p *Part) SetBlob(blob []byte)
- func (p *Part) SetPartname(partname PackURI)
- type Relationship
- type RelationshipTargetMode
- type RelationshipType
- type Relationships
- func (r *Relationships) Get(rID string) (*Relationship, bool)
- func (r *Relationships) GetOrAdd(relType RelationshipType, targetPart *Part) string
- func (r *Relationships) GetOrAddExtRel(relType RelationshipType, targetRef string) string
- func (r *Relationships) Keys() []string
- func (r *Relationships) Len() int
- func (r *Relationships) LoadFromXML(baseURI string, relXML []byte, parts map[PackURI]*Part) error
- func (r *Relationships) PartWithRelType(relType RelationshipType) (*Part, error)
- func (r *Relationships) Pop(rID string) (*Relationship, error)
- func (r *Relationships) ToXML() ([]byte, error)
- func (r *Relationships) Values() []*Relationship
- type ShapeContent
- type SldId
- type SlideContent
- type TableContent
- type TextContent
- type ThemeContent
- type TransitionContent
- type URLContent
- type VideoContent
- type XmlPart
Constants ¶
const ( ContentTypesURI = "[Content_Types].xml" PackageURI = "/" )
OPC related constants
const ( ExternalNode string = "external" // 外部节点 ImageNode string = "image/png" // 图像节点 VideoNode string = "video/mp4" // 视频节点 AudioNode string = "audio/mpeg" // 音频节点 TableNode string = "table" // 表格节点 TextNode string = "text" // 文本节点 CommentNode string = "comment" // 批注节点 SlideNode string = "slide" // 幻灯片节点 NoteNode string = "note" // 备注节点 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AnimationContent ¶
type AnimationContent struct {
SlideNumber int // 幻灯片编号
Sequence int // 动画序号
Effect string // 动画效果
TargetID string // 动画目标元素ID
Duration string // 动画持续时间
Delay string // 动画延迟时间
Metadata map[string]string // 元数据
}
AnimationContent 表示动画内容
type AudioContent ¶
type AudioContent struct {
SlideNumber int // 幻灯片编号
Content []byte // 音频内容
Path string // 音频在PPT中的路径
Format string // 音频格式
Duration string // 音频持续时间
AutoPlay bool // 是否自动播放
Metadata map[string]string // 元数据
}
AudioContent 表示音频内容
type ChartContent ¶
type ChartContent struct {
SlideNumber int // 幻灯片编号
Type string // 图表类型
Title string // 图表标题
Data [][]string // 图表数据
Position string // 位置信息
Metadata map[string]string // 元数据
}
ChartContent 表示图表内容
type CommentContent ¶
type CommentContent struct {
SlideNumber int // 幻灯片编号
Author string // 作者名称
Text string // 批注内容
Date string // 批注日期
Position string // 位置信息
}
CommentContent 表示批注内容
type ContentTypeMap ¶
type ContentTypeMap struct {
// contains filtered or unexported fields
}
ContentTypeMap maps part names to content types
func NewContentTypeMap ¶
func NewContentTypeMap(overrides, defaults map[string]string) *ContentTypeMap
NewContentTypeMap creates a new content type map
func (*ContentTypeMap) FromXML ¶
func (c *ContentTypeMap) FromXML(contentTypesXML []byte) error
FromXML creates a ContentTypeMap from XML
func (*ContentTypeMap) GetContentType ¶
func (c *ContentTypeMap) GetContentType(partname PackURI) (string, error)
GetContentType returns the content type for a part
type ImageContent ¶
type ImageContent struct {
SlideNumber int // 幻灯片编号
Content []byte // 图像内容
Path string // 图像在PPT中的路径
Alt string // 替代文本
Position string // 位置信息
Size string // 尺寸信息
Metadata map[string]string // 元数据
}
ImageContent 表示图像内容
type MacroContent ¶
MacroContent 表示宏/VBA内容
type MasterSlideContent ¶
type MasterSlideContent struct {
Name string // 母版名称
Elements []interface{} // 母版中的元素
Metadata map[string]string // 元数据
}
MasterSlideContent 表示母版内容
type NoteContent ¶
NoteContent 表示备注内容
type OpcPackage ¶
type OpcPackage struct {
// contains filtered or unexported fields
}
OpcPackage represents a PPTX package
func NewOpcPackage ¶
func NewOpcPackage(pkgFile interface{}) *OpcPackage
NewOpcPackage creates a new package
func OpenOpcPackage ¶
func OpenOpcPackage(pkgFile interface{}) (*OpcPackage, error)
Open opens a package from a file
func (*OpcPackage) IterParts ¶
func (p *OpcPackage) IterParts() []*Part
IterParts iterates over all parts in the package
func (*OpcPackage) MainDocumentPart ¶
func (p *OpcPackage) MainDocumentPart() (*Part, error)
MainDocumentPart returns the main document part
func (*OpcPackage) PartRelatedBy ¶
func (p *OpcPackage) PartRelatedBy(relType RelationshipType) (*Part, error)
PartRelatedBy returns the part related by the given relationship type
func (*OpcPackage) Rels ¶
func (p *OpcPackage) Rels() *Relationships
Rels returns the package relationships
func (*OpcPackage) Save ¶
func (p *OpcPackage) Save(pkgFile interface{}) error
Save saves the package to a file
type PPTClassifier ¶
type PPTClassifier struct {
Images []*ImageContent // 所有图像内容
Urls []*URLContent // 所有URL内容
Videos []*VideoContent // 所有视频内容
Slides []*SlideContent // 所有幻灯片内容
Tables []*TableContent // 所有表格内容
Audios []*AudioContent // 所有音频内容
Notes []*NoteContent // 所有备注内容
Texts []*TextContent // 所有文本内容
Comments []*CommentContent // 所有批注内容
MasterSlides []*MasterSlideContent // 所有母版内容
Themes []*ThemeContent // 所有主题内容
Animations []*AnimationContent // 所有动画内容
Transitions []*TransitionContent // 所有转场效果内容
Macros []*MacroContent // 所有宏内容
}
PPTClassifier 用于分类PPT节点
func (*PPTClassifier) DumpToFiles ¶
func (c *PPTClassifier) DumpToFiles() map[string][]types.File
DumpToFiles 将分类后的节点转换为文件
type PPTNode ¶
type PPTNode struct {
Type string // 节点类型
Content interface{} // 节点内容
}
PPTNode 表示 PPT 文档中的一个节点
type PPTXParser ¶
type PPTXParser struct {
// contains filtered or unexported fields
}
PPTXParser is the parser for PPTX files using OPC (Open Packaging Convention)
func (*PPTXParser) Parse ¶
func (p *PPTXParser) Parse() ([]PPTNode, error)
Parse parses the PPTX file
type PackURI ¶
type PackURI struct {
URI string
}
PackURI represents a package part URI
func (PackURI) FromRelRef ¶
FromRelRef creates a PackURI from a relative reference
func (PackURI) RelativeRef ¶
RelativeRef returns the relative reference of this URI to a base URI
type PackageLoader ¶
type PackageLoader struct {
// contains filtered or unexported fields
}
PackageLoader loads a package from a file
func NewPackageLoader ¶
func NewPackageLoader(pkgFile interface{}, pkg *OpcPackage) *PackageLoader
NewPackageLoader creates a new package loader
type Part ¶
type Part struct {
// contains filtered or unexported fields
}
Part represents a part in the package
func NewPart ¶
func NewPart(partname PackURI, contentType string, pkg *OpcPackage, blob []byte) *Part
NewPart creates a new part
func (*Part) LoadRelsFromXML ¶
LoadRelsFromXML loads relationships from XML
func (*Part) PartRelatedBy ¶
func (p *Part) PartRelatedBy(relType RelationshipType) (*Part, error)
PartRelatedBy returns the part related by the given relationship type
func (*Part) RelatedPart ¶
RelatedPart returns the related part with the given relationship ID
func (*Part) SetPartname ¶
SetPartname sets the part name
type Relationship ¶
type Relationship struct {
// contains filtered or unexported fields
}
Relationship represents a relationship between parts
func NewRelationship ¶
func NewRelationship(baseURI, rID string, relType RelationshipType, targetMode RelationshipTargetMode, target interface{}) *Relationship
NewRelationship creates a new relationship
func (*Relationship) IsExternal ¶
func (r *Relationship) IsExternal() bool
IsExternal returns true if the relationship is external
func (*Relationship) RelType ¶
func (r *Relationship) RelType() RelationshipType
RelType returns the relationship type
func (*Relationship) TargetPart ¶
func (r *Relationship) TargetPart() (*Part, error)
TargetPart returns the target part of the relationship
func (*Relationship) TargetRef ¶
func (r *Relationship) TargetRef() string
TargetRef returns the target reference of the relationship
type RelationshipTargetMode ¶
type RelationshipTargetMode string
RelationshipTargetMode defines the target mode for relationships
const ( RelationshipTargetModeInternal RelationshipTargetMode = "Internal" RelationshipTargetModeExternal RelationshipTargetMode = "External" )
type RelationshipType ¶
type RelationshipType string
RelationshipType defines common relationship types
const (
RelationshipTypeOfficeDocument RelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
)
type Relationships ¶
type Relationships struct {
// contains filtered or unexported fields
}
Relationships represents a collection of relationships
func NewRelationships ¶
func NewRelationships(baseURI string) *Relationships
NewRelationships creates a new relationships collection
func (*Relationships) Get ¶
func (r *Relationships) Get(rID string) (*Relationship, bool)
Get returns the relationship with the given ID
func (*Relationships) GetOrAdd ¶
func (r *Relationships) GetOrAdd(relType RelationshipType, targetPart *Part) string
GetOrAdd adds a relationship or returns an existing one
func (*Relationships) GetOrAddExtRel ¶
func (r *Relationships) GetOrAddExtRel(relType RelationshipType, targetRef string) string
GetOrAddExtRel adds an external relationship or returns an existing one
func (*Relationships) Keys ¶
func (r *Relationships) Keys() []string
Keys returns the keys of the relationships collection
func (*Relationships) Len ¶
func (r *Relationships) Len() int
Len returns the number of relationships
func (*Relationships) LoadFromXML ¶
LoadFromXML loads relationships from XML
func (*Relationships) PartWithRelType ¶
func (r *Relationships) PartWithRelType(relType RelationshipType) (*Part, error)
PartWithRelType returns the part with the given relationship type
func (*Relationships) Pop ¶
func (r *Relationships) Pop(rID string) (*Relationship, error)
Pop removes a relationship and returns it
func (*Relationships) ToXML ¶
func (r *Relationships) ToXML() ([]byte, error)
ToXML serializes relationships to XML
func (*Relationships) Values ¶
func (r *Relationships) Values() []*Relationship
Values returns the values of the relationships collection
type ShapeContent ¶
type ShapeContent struct {
SlideNumber int // 幻灯片编号
Type string // 形状类型
Text string // 形状中的文本
Position string // 位置信息
Style string // 形状样式
Metadata map[string]string // 元数据
}
ShapeContent 表示形状内容
type SlideContent ¶
type SlideContent struct {
SlideNumber int // 幻灯片编号
Title string // 幻灯片标题
Layout string // 幻灯片布局
Nodes []PPTNode //
Metadata map[string]string // 元数据
}
SlideContent 表示幻灯片内容
type TableContent ¶
type TableContent struct {
SlideNumber int // 幻灯片编号
Headers []string // 表头
Rows [][]string // 数据行
Position string // 位置信息
Style string // 表格样式
Metadata map[string]string // 元数据
}
TableContent 表示表格内容
type TextContent ¶
type TextContent struct {
SlideNumber int // 幻灯片编号
Text string // 文本内容
Position string // 位置信息
FontInfo map[string]string // 字体信息
IsTitle bool // 是否为标题
Level int // 列表级别,0表示不是列表项
}
TextContent 表示文本内容
type ThemeContent ¶
type ThemeContent struct {
Name string // 主题名称
Colors []string // 主题颜色
Fonts []string // 主题字体
Background string // 主题背景
Metadata map[string]string // 元数据
}
ThemeContent 表示主题内容
type TransitionContent ¶
type TransitionContent struct {
SlideNumber int // 幻灯片编号
Type string // 转场类型
Duration string // 转场持续时间
Sound string // 转场声音
Trigger string // 转场触发方式
}
TransitionContent 表示转场效果内容
type URLContent ¶
type URLContent struct {
SlideNumber int // 幻灯片编号
URL string // URL内容
DisplayText string // 显示文本
Position string // 位置信息
Metadata map[string]string // 元数据
}
URLContent 表示URL内容
type VideoContent ¶
type VideoContent struct {
SlideNumber int // 幻灯片编号
Content []byte // 视频内容
Path string // 视频在PPT中的路径
Position string // 位置信息
Size string // 尺寸信息
Format string // 视频格式
Duration string // 视频持续时间
BinaryData []byte // 视频二进制数据
Metadata map[string]string // 元数据
}
VideoContent 表示视频内容
type XmlPart ¶
type XmlPart struct {
*Part
// contains filtered or unexported fields
}
XmlPart represents a part containing XML
func NewXmlPart ¶
func NewXmlPart(partname PackURI, contentType string, pkg *OpcPackage, element interface{}) *XmlPart
NewXmlPart creates a new XML part