Documentation
¶
Index ¶
- Constants
- Variables
- type AdjustValue
- type AdjustValueList
- type BodyProperties
- type CommonNonVisualGroupShapeProperties
- type CommonNonVisualProperties
- type CommonNonVisualShapeProperties
- type ErrSlideNotExist
- type Extents
- type File
- func (f *File) Close() error
- func (f *File) GetGroupShapeProperties(slideID int) (*decodeGroupShapeProperties, error)
- func (f *File) GetNonVisualGroupShapeProperties(slideID int) (*decodeNonVisualGroupShapeProperties, error)
- func (f *File) GetShapes(slideID int) ([]decodeShape, error)
- func (f *File) NewSlide() (int, error)
- func (f *File) ReadZipReader(r *zip.Reader) (map[string][]byte, int, error)
- func (f *File) Save(opts ...Options) error
- func (f *File) SaveAs(name string, opts ...Options) error
- func (f *File) Write(w io.Writer, opts ...Options) error
- func (f *File) WriteTo(w io.Writer, opts ...Options) (int64, error)
- func (f *File) WriteToBuffer() (*bytes.Buffer, error)
- type GroupShapeProperties
- type Latin
- type Line
- type LineSpacing
- type NoAutofit
- type NonVisualGroupShapeProperties
- type NonVisualProperties
- type NonVisualShapeProperties
- type Offset
- type Options
- type Paragraph
- type ParagraphProperties
- type Ph
- type PresetGeometry
- type RunProperties
- type Runs
- type Shape
- type ShapeLocks
- type ShapeProperties
- type ShapeTree
- type Slide
- type SlideData
- type SolidFill
- type SolidRGBColor
- type SpacingPercent
- type StreamWriter
- type TextBody
- type Xfrm
- type ZipWriter
Constants ¶
const ( MaxFilePathLength = 207 StreamChunkSize = 1 << 24 UnzipSizeLimit = 1000 << 24 )
const ( ContentTypePresentationML = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" ContentTypeSlideML = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml" ContentTypeRelationships = "application/vnd.openxmlformats-package.relationships+xml" ContentTypeVBA = "application/vnd.ms-office.vbaProject" NameSpaceDrawingMLMain = "http://schemas.openxmlformats.org/drawingml/2006/main" NameSpaceExtendedProperties = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" NameSpaceXML = "http://www.w3.org/XML/1998/namespace" SourceRelationshipCustomProperties = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" SourceRelationshipOfficeDocument = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" SourceRelationshipSlide = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" StrictNameSpaceDocumentPropertiesVariantTypes = "http://purl.oclc.org/ooxml/officeDocument/docPropsVTypes" StrictNameSpaceDrawingMLMain = "http://purl.oclc.org/ooxml/drawingml/main" StrictNameSpaceExtendedProperties = "http://purl.oclc.org/ooxml/officeDocument/extendedProperties" NameSpacePresentationMLMain = "http://schemas.openxmlformats.org/presentationml/2006/main" StrictNameSpacePresentationMLMain = "http://purl.oclc.org/ooxml/presentationml/main" )
const (
MaxFieldLength = 255
)
Variables ¶
var ( // ErrPasswordLengthInvalid defined the error message on invalid password // length. ErrPasswordLengthInvalid = errors.New("password length invalid") // ErrOptionsUnzipSizeLimit defined the error message for receiving // invalid UnzipSizeLimit and UnzipXMLSizeLimit. ErrOptionsUnzipSizeLimit = errors.New("the value of UnzipSizeLimit should be greater than or equal to UnzipXMLSizeLimit") // ErrMaxFilePathLength defined the error message on receive the file path // length overflow. ErrMaxFilePathLength = fmt.Errorf("file path length exceeds maximum limit %d characters", MaxFilePathLength) // ErrSave defined the error message for saving file. ErrSave = errors.New("no path defined for file, consider File.WriteTo or File.Write") // ErrUnsupportedEncryptMechanism defined the error message on receive the blank slide name. ErrSlideNameBlank = errors.New("the slide name can not be blank") // ErrPresentationFileFormat defined the error message on receive an // unsupported presentation file format. ErrPresentationFileFormat = errors.New("unsupported presentation file format") )
var ( //go:embed templates/slide1.xml TemplateSlide string //go:embed templates/slide1-rels.xml TemplateSlideRels string )
var ( NameSpaceDocumentPropertiesVariantTypes = xml.Attr{Name: xml.Name{Local: "vt", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"} NameSpaceDrawing2016SVG = xml.Attr{Name: xml.Name{Local: "asvg", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2016/SVG/main"} NameSpaceDrawingML = xml.Attr{Name: xml.Name{Local: "a", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/main"} NameSpaceDrawingMLA14 = xml.Attr{Name: xml.Name{Local: "a14", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2010/main"} NameSpaceDrawingMLChart = xml.Attr{Name: xml.Name{Local: "c", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/chart"} NameSpaceDrawingMLSlicer = xml.Attr{Name: xml.Name{Local: "sle", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2010/slicer"} NameSpaceDrawingMLSlicerX15 = xml.Attr{Name: xml.Name{Local: "sle15", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2012/slicer"} SourceRelationship = xml.Attr{Name: xml.Name{Local: "r", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships"} SourceRelationshipCompatibility = xml.Attr{Name: xml.Name{Local: "mc", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/markup-compatibility/2006"} NameSpacePresentationML = xml.Attr{Name: xml.Name{Local: "p", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/presentationml/2006/main"} NameSpacePowerPointR14 = xml.Attr{Name: xml.Name{Local: "p14", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/powerpoint/2010/main"} NameSpacePowerPointR15 = xml.Attr{Name: xml.Name{Local: "p15", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/powerpoint/2012/main"} )
Functions ¶
This section is empty.
Types ¶
type AdjustValue ¶
type AdjustValueList ¶ added in v0.2.0
type AdjustValueList struct {
}
type BodyProperties ¶
type CommonNonVisualGroupShapeProperties ¶
type CommonNonVisualGroupShapeProperties struct{}
type CommonNonVisualShapeProperties ¶
type CommonNonVisualShapeProperties struct {
TxBox *bool `xml:"txBox,attr,omitempty"`
ShapeLocks *ShapeLocks `xml:"a:spLocks,omitempty"`
}
type ErrSlideNotExist ¶
type ErrSlideNotExist struct {
SlideID int
}
ErrSlideNotExist defined an error of slide that does not exist.
func (ErrSlideNotExist) Error ¶
func (err ErrSlideNotExist) Error() string
Error returns the error message on receiving the non existing slide name.
type File ¶
type File struct {
CharsetReader func(charset string, input io.Reader) (rdr io.Reader, err error)
ContentTypes *contentTypes
Path string
Pkg sync.Map
Presentation *decodePresentation
Relationships sync.Map
Slide sync.Map
SlideCount int
Theme *decodeTheme
ZipWriter func(io.Writer) ZipWriter
// contains filtered or unexported fields
}
File define a populated slides file struct.
func NewFile ¶ added in v0.1.0
NewFile provides a function to create new file by default template. For example:
f := NewFile()
func OpenFile ¶
OpenFile take the name of a presentation file and returns a populated presentation file struct for it.
Close the file by Close function after opening the slides.
func OpenReader ¶
OpenReader read data stream from io.Reader and return a populated presentation file.
func (*File) GetGroupShapeProperties ¶ added in v0.0.2
GetGroupShapeProperties provides a function to get group shape properties by given slide id.
func (*File) GetNonVisualGroupShapeProperties ¶ added in v0.0.2
func (f *File) GetNonVisualGroupShapeProperties(slideID int) (*decodeNonVisualGroupShapeProperties, error)
GetNonVisualGroupShapeProperties provides a function to get non visual group shape properties by given slide id.
func (*File) NewSlide ¶ added in v0.2.0
NewSlide provides the function to create a new slide and returns the index of the slide in the presentation after it appended.
func (*File) ReadZipReader ¶
ReadZipReader extract presentation with given options.
func (*File) Save ¶ added in v0.1.0
Save provides a function to override the presentation with origin path.
func (*File) SaveAs ¶ added in v0.1.0
SaveAs provides a function to create or update to a presentation at the provided path.
type GroupShapeProperties ¶
type GroupShapeProperties struct {
Xfrm *Xfrm `xml:"a:xfrm"`
}
type Line ¶
type Line struct {
Width *int `xml:"w,attr,omitempty"`
NoFill *noFill `xml:"a:noFill,omitempty"`
}
type LineSpacing ¶
type LineSpacing struct {
SpacingPercent *SpacingPercent `xml:"spcPct"`
}
type NonVisualGroupShapeProperties ¶
type NonVisualGroupShapeProperties struct {
CommonNonVisualProperties *CommonNonVisualProperties `xml:"p:cNvPr"`
CommonNonVisualGroupShapeProperties *CommonNonVisualGroupShapeProperties `xml:"p:cNvGrpSpPr"`
NonVisualProperties *NonVisualProperties `xml:"p:nvPr"`
}
type NonVisualProperties ¶
type NonVisualProperties struct {
Ph *Ph `xml:"p:ph,omitempty"`
}
type NonVisualShapeProperties ¶
type NonVisualShapeProperties struct {
CommonNonVisualProperties *CommonNonVisualProperties `xml:"p:cNvPr"`
CommonNonVisualShapeProperties *CommonNonVisualShapeProperties `xml:"p:cNvSpPr"`
NonVisualProperties *NonVisualProperties `xml:"p:nvPr"`
}
type Paragraph ¶
type Paragraph struct {
ParagraphProperties *ParagraphProperties `xml:"a:pPr,omitempty"`
Runs []Runs `xml:"r"`
EndParagraphRunProperties *RunProperties `xml:"a:endParaRPr,omitempty"`
}
type ParagraphProperties ¶
type ParagraphProperties struct {
Indent *int `xml:"indent,attr,omitempty"`
Align *string `xml:"algn,attr,omitempty"`
LineSpacing *LineSpacing `xml:"lnSpc,omitempty"`
BuNone *struct{} `xml:"buNone,omitempty"`
}
type PresetGeometry ¶
type PresetGeometry struct {
Preset string `xml:"prst,attr"`
AdjustValueList *AdjustValueList `xml:"a:avLst"`
}
type RunProperties ¶
type RunProperties struct {
Bold *int `xml:"b,attr,omitempty"`
Lang string `xml:"lang,attr,omitempty"`
Size *int `xml:"sz,attr,omitempty"`
Space *int `xml:"spc,attr,omitempty"`
Strike string `xml:"strike,attr,omitempty"`
SolidFill *SolidFill `xml:"a:solidFill,omitempty"`
Latin *Latin `xml:"a:latin,omitempty"`
}
type Runs ¶
type Runs struct {
RunProperties *decodeRunProperties `xml:"rPr,omitempty"`
Text string `xml:"t"`
}
type Shape ¶
type Shape struct {
NonVisualShapeProperties *NonVisualShapeProperties `xml:"p:nvSpPr"`
ShapeProperties *ShapeProperties `xml:"p:spPr"`
TextBody *TextBody `xml:"p:txBody,omitempty"`
}
type ShapeLocks ¶ added in v0.2.0
type ShapeLocks struct {
NoGroup *int `xml:"noGrp,attr,omitempty"`
}
type ShapeProperties ¶
type ShapeProperties struct {
Xfrm *Xfrm `xml:"a:xfrm"`
PresetGeometry *PresetGeometry `xml:"a:prstGeom,omitempty"`
NoFill *noFill `xml:"a:noFill,omitempty"`
Ln *Line `xml:"a:ln,omitempty"`
}
type ShapeTree ¶
type ShapeTree struct {
NonVisualGroupShapeProperties *NonVisualGroupShapeProperties `xml:"p:nvGrpSpPr,omitempty"`
GroupShapeProperties *GroupShapeProperties `xml:"p:grpSpPr,omitempty"`
Shape []Shape `xml:"p:sp"`
}
type Slide ¶
type Slide struct {
XMLName xml.Name `xml:"p:sld"`
XMLNSA string `xml:"xmlns:a,attr"`
XMLNSP string `xml:"xmlns:p,attr"`
XMLNSR string `xml:"xmlns:r,attr"`
XMLNSP14 string `xml:"xmlns:p14,attr"`
XMLNSP15 string `xml:"xmlns:p15,attr"`
XMLNSMC string `xml:"xmlns:mc,attr"`
CommonSlideData SlideData `xml:"p:cSld"`
AlternateContent *alternateContent `xml:"mc:AlternateContent"`
DecodeAlternateContent *innerXML `xml:"http://schemas.openxmlformats.org/markup-compatibility/2006 AlternateContent"`
// contains filtered or unexported fields
}
type SolidFill ¶
type SolidFill struct {
SolidRGBColor *SolidRGBColor `xml:"a:srgbClr"`
}
type SolidRGBColor ¶
type SolidRGBColor struct {
Val string `xml:"val,attr"`
}
type SpacingPercent ¶
type SpacingPercent struct {
Val int `xml:"val,attr"`
}
type StreamWriter ¶
type TextBody ¶
type TextBody struct {
BodyProperties *BodyProperties `xml:"a:bodyPr"`
Paragraph []Paragraph `xml:"a:p"`
}
type ZipWriter ¶
type ZipWriter interface {
Create(name string) (io.Writer, error)
AddFS(fsys fs.FS) error
Close() error
}
ZipWriter defines an interface for writing files to a ZIP archive. It provides methods to create new files within the archive, add files from a filesystem, and close the archive when writing is complete.