Documentation ¶
Overview ¶
pptx is a package to create slide presentations in pptx (Microsoft Power Point) format. A `.pptx` file is just a bunch of zip compressed `.xml` files following the Office Open XML (OOXML) format. To see its content, you can just `unzip <path/to/file>.pptx -d <folder>`. With this package, it is possible to create a `Presentation` and add `Slide`s to it. Then, when saving the presentation, it will generate the required `.xml` files, compress them and write to the disk. Note that this isn't a full implementation of the OOXML format, but a wrapper around it. There's a base template with common files to the presentation and then when saving, the package generate only the slides and relationships. The base template and slide templates were generated using https://python-pptx.readthedocs.io/en/latest/ For more information about OOXML, check http://officeopenxml.com/index.php
Index ¶
- Constants
- Variables
- func Validate(pptxContent []byte, nSlides int) error
- type AppXmlContent
- type BoardTitle
- type ContentTypesXmlContent
- type CoreXmlContent
- type Link
- type Presentation
- type PresentationSlideXmlContent
- type PresentationXmlContent
- type RelsPresentationSlideXmlContent
- type RelsPresentationXmlContent
- type RelsSlideXmlContent
- type RelsSlideXmlLinkContent
- type Slide
- type SlideLinkXmlContent
- type SlideXmlContent
- type SlideXmlTitlePathContent
Constants ¶
const HEADER_HEIGHT = 392_471
const IMAGE_ASPECT_RATIO = float64(IMAGE_WIDTH) / float64(IMAGE_HEIGHT)
const IMAGE_HEIGHT = SLIDE_HEIGHT - HEADER_HEIGHT
const IMAGE_WIDTH = 8_446_273
keep the right aspect ratio: SLIDE_WIDTH / SLIDE_HEIGHT = IMAGE_WIDTH / IMAGE_HEIGHT
const SLIDE_HEIGHT = 5_143_500
const SLIDE_WIDTH = 9_144_000
Measurements in OOXML are made in English Metric Units (EMUs) where 1 inch = 914,400 EMUs The intent is to have a measurement unit that doesn't require floating points when dealing with centimeters, inches, points (DPI). Office Open XML (OOXML) http://officeopenxml.com/prPresentation.php https://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/
Variables ¶
var APP_XML string
var CONTENT_TYPES_XML string
var CORE_XML string
var PPTX_TEMPLATE []byte
var PRESENTATION_XML string
var RELS_PRESENTATION_XML string
var RELS_SLIDE_XML string
var SLIDE_XML string
Functions ¶
Types ¶
type AppXmlContent ¶
type BoardTitle ¶
type ContentTypesXmlContent ¶
type ContentTypesXmlContent struct {
FileNames []string
}
type CoreXmlContent ¶
type Presentation ¶
type Presentation struct { Title string Description string Subject string Creator string // D2Version can't have letters, only numbers (`[0-9]`) and `.` // Otherwise, it may fail to open in PowerPoint D2Version string Slides []*Slide }
func NewPresentation ¶
func NewPresentation(title, description, subject, creator, d2Version string) *Presentation
func (*Presentation) AddSlide ¶
func (p *Presentation) AddSlide(pngContent []byte, titlePath []BoardTitle) (*Slide, error)
func (*Presentation) SaveTo ¶
func (p *Presentation) SaveTo(filePath string) error
type PresentationXmlContent ¶
type PresentationXmlContent struct { SlideWidth int SlideHeight int Slides []PresentationSlideXmlContent }
type RelsPresentationXmlContent ¶
type RelsPresentationXmlContent struct {
Slides []RelsPresentationSlideXmlContent
}
type RelsSlideXmlContent ¶
type RelsSlideXmlContent struct { FileName string RelationshipID string Links []RelsSlideXmlLinkContent }
type RelsSlideXmlLinkContent ¶
type Slide ¶
type SlideLinkXmlContent ¶
type SlideXmlContent ¶
type SlideXmlContent struct { Title string TitlePrefix []SlideXmlTitlePathContent Description string HeaderHeight int ImageID string ImageLeft int ImageTop int ImageWidth int ImageHeight int Links []SlideLinkXmlContent }