pptx

package module
v0.0.0-...-3e65857 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

pptx

A Golang library for replacing text or image in pptx file

For the method of processing pptx files, refer to https://github.com/nguyenthenguyen/docx

About

The library replacing text or image in slides,Supported image formats are "png" "jepg" "jpg",Other formats haven't been tested yet. Maybe they can

delete password only document edit password

the theme rename

test file password is 123456

Examples
package main

import (
	"fmt"
	"github.com/moipa-cn/pptx"
)

func main() {
	p,_:=pptx.ReadPowerPoint("./test.pptx")
	img := "./test.jpg"
	p.DeletePassWord()
	p.ReplaceSlideContent("A Golang library", "welcome", -1)
	p.ReplaceNotesSlideContent("TEST NotesSlides", "New NotesSlide", -1)
	p.ReplaceThemeName("ThemeName", "NewThemeName", -1)
	//This slide is not really deleted, it will be moved to the last page and empty the content
	err := p.DeleteSlide(-1)
	if err != nil {
		fmt.Println(err)
	}
	p.ReplaceImage(img, 1)
	p.WriteToFile("./test_1.pptx")
}
Todo
  1. ppt to pptx
  2. pptx to img
  3. pptx to pdf
  4. add slide
  5. replace theme

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PowerPoint

type PowerPoint struct {
	Files        []*zip.File
	Slides       map[string]string
	NotesSlides  map[string]string
	Themes       map[string]string
	Images       map[string]string
	Presentation string
}

func ReadPowerPoint

func ReadPowerPoint(path string) (*PowerPoint, error)

func (*PowerPoint) DeletePassWord

func (p *PowerPoint) DeletePassWord()

只能删除文本编辑密码

func (*PowerPoint) DeleteSlide

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

func (*PowerPoint) GetNotesSlideCount

func (p *PowerPoint) GetNotesSlideCount() int

func (*PowerPoint) GetSlideCount

func (p *PowerPoint) GetSlideCount() int

func (*PowerPoint) GetSlidesContent

func (p *PowerPoint) GetSlidesContent() []string

func (*PowerPoint) GetThemeCount

func (p *PowerPoint) GetThemeCount() int

func (*PowerPoint) ReplaceImage

func (p *PowerPoint) ReplaceImage(newImagePath string, index int) error

func (*PowerPoint) ReplaceNotesSlideContent

func (p *PowerPoint) ReplaceNotesSlideContent(oldString string, newString string, num int)

func (*PowerPoint) ReplaceSlideContent

func (p *PowerPoint) ReplaceSlideContent(oldString string, newString string, num int)

func (*PowerPoint) ReplaceThemeName

func (p *PowerPoint) ReplaceThemeName(oldString string, newString string, num int)

func (*PowerPoint) Write

func (p *PowerPoint) Write(ioWriter io.Writer) (err error)

func (*PowerPoint) WriteToFile

func (p *PowerPoint) WriteToFile(path string) (err error)

Jump to

Keyboard shortcuts

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