1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-05 07:40:24 +08:00

feat: A3PageSize (#22)

* feat: A3PageSize

* feat: A3PageSize2

* feat: A3PageSize3

* feat: A3PageSize3

* feat: A3PageSize4

* Update structsect.go

---------

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
This commit is contained in:
mabiao0525
2024-03-19 15:49:12 +08:00
committed by GitHub
parent f875425b6e
commit d74423910a
6 changed files with 140 additions and 15 deletions

View File

@@ -20,7 +20,10 @@
package docx
import "io/fs"
import (
"encoding/xml"
"io/fs"
)
// UseTemplate will replace template files
func (f *Docx) UseTemplate(template string, tmpfslst []string, tmplfs fs.FS) *Docx {
@@ -34,3 +37,27 @@ func (f *Docx) UseTemplate(template string, tmpfslst []string, tmplfs fs.FS) *Do
func (f *Docx) WithDefaultTheme() *Docx {
return f.UseTemplate("default", DefaultTemplateFilesList, TemplateXMLFS)
}
// WithA3Page use A3 PageSize
func (f *Docx) WithA3Page() *Docx {
sectpr := &SectPr{
PgSz: &PgSz{
W: xml.Attr{Name: xml.Name{Local: "w:w"}, Value: "16838"},
H: xml.Attr{Name: xml.Name{Local: "w:h"}, Value: "23811"},
},
}
f.Document.Body.Items = append(f.Document.Body.Items, sectpr)
return f
}
// WithA4Page use A4 PageSize
func (f *Docx) WithA4Page() *Docx {
sectpr := &SectPr{
PgSz: &PgSz{
W: xml.Attr{Name: xml.Name{Local: "w:w"}, Value: "11906"},
H: xml.Attr{Name: xml.Name{Local: "w:h"}, Value: "16838"},
},
}
f.Document.Body.Items = append(f.Document.Body.Items, sectpr)
return f
}