From f58a6802133a2b6429f4fa373b772ca67e4a170e Mon Sep 17 00:00:00 2001 From: guoqiang Date: Thu, 19 Dec 2024 16:08:42 +0800 Subject: [PATCH 01/16] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DFont=E5=AD=97?= =?UTF-8?q?=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apirun.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apirun.go b/apirun.go index e5d5128..c87f10a 100644 --- a/apirun.go +++ b/apirun.go @@ -100,11 +100,12 @@ func (r *Run) AddTab() *Run { } // Font sets the font of the run -func (r *Run) Font(ascii, hansi, hint string) *Run { +func (r *Run) Font(ascii, eastAsia, hansi, hint string) *Run { r.RunProperties.Fonts = &RunFonts{ - ASCII: ascii, - HAnsi: hansi, - Hint: hint, + ASCII: ascii, + EastAsia: eastAsia, + HAnsi: hansi, + Hint: hint, } return r } From 9c4b4cefa4af9d7157de0ba7fb3177e94585daa0 Mon Sep 17 00:00:00 2001 From: guoqiang Date: Thu, 19 Dec 2024 16:16:15 +0800 Subject: [PATCH 02/16] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dmodule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index fc3f48f..e34b152 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/fumiama/go-docx +module github.com/l0g1n/go-docx go 1.20 From 19779b70d881f22e763d40ecf2b3576476136174 Mon Sep 17 00:00:00 2001 From: guoqiang Date: Thu, 19 Dec 2024 16:18:07 +0800 Subject: [PATCH 03/16] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dmain=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/main/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/main/main.go b/cmd/main/main.go index 103cfaa..0d060ef 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -30,7 +30,7 @@ import ( "strconv" "strings" - "github.com/fumiama/go-docx" + "github.com/l0g1n/go-docx" ) func main() { @@ -66,11 +66,11 @@ func main() { para1.AddText("italic").Italic().AddTab() para1.AddText("underline").Underline("double").AddTab() para1.AddText("highlight").Highlight("yellow").AddTab() - para1.AddText("font").Font("Consolas", "", "cs").AddTab() + para1.AddText("font").Font("Consolas", "", "", "cs").AddTab() para2 := w.AddParagraph().Justification("end") para2.AddText("test all font attrs"). - Size("44").Color("ff0000").Font("Consolas", "", "cs"). + Size("44").Color("ff0000").Font("Consolas", "", "", "cs"). Shade("clear", "auto", "E7E6E6"). Bold().Italic().Underline("wave"). Highlight("yellow") From 32af237c18e7c6623cb6cb26741b13dbc9dd2b69 Mon Sep 17 00:00:00 2001 From: guoqiang Date: Thu, 19 Dec 2024 16:32:06 +0800 Subject: [PATCH 04/16] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dmain=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 +++- go.sum | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e34b152..2166108 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,6 @@ module github.com/l0g1n/go-docx go 1.20 -require github.com/fumiama/imgsz v0.0.2 +require github.com/fumiama/imgsz v0.0.4 + +require golang.org/x/image v0.23.0 // indirect diff --git a/go.sum b/go.sum index ac04f3a..846ab56 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,4 @@ -github.com/fumiama/imgsz v0.0.2 h1:fAkC0FnIscdKOXwAxlyw3EUba5NzxZdSxGaq3Uyfxak= -github.com/fumiama/imgsz v0.0.2/go.mod h1:dR71mI3I2O5u6+PCpd47M9TZptzP+39tRBcbdIkoqM4= +github.com/fumiama/imgsz v0.0.4 h1:Lsasu2hdSSFS+vnD+nvR1UkiRMK7hcpyYCC0FzgSMFI= +github.com/fumiama/imgsz v0.0.4/go.mod h1:bISOQVTlw9sRytPwe8ir7tAaEmyz9hSNj9n8mXMBG0E= +golang.org/x/image v0.23.0 h1:HseQ7c2OpPKTPVzNjG5fwJsOTCiiwS4QdsYi5XU6H68= +golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= From 1679c7e9940c5c15b4e97f5e0bb181035702f22b Mon Sep 17 00:00:00 2001 From: guoqiang Date: Thu, 19 Dec 2024 17:21:27 +0800 Subject: [PATCH 05/16] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0SizeCs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apirun.go | 8 ++++++++ go.mod | 4 +--- go.sum | 6 ++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apirun.go b/apirun.go index c87f10a..d302a06 100644 --- a/apirun.go +++ b/apirun.go @@ -36,6 +36,14 @@ func (r *Run) Size(size string) *Run { return r } +// SizeCs allows to set run size +func (r *Run) SizeCs(size string) *Run { + r.RunProperties.SizeCs = &SizeCs{ + Val: size, + } + return r +} + // Shade allows to set run shade func (r *Run) Shade(val, color, fill string) *Run { r.RunProperties.Shade = &Shade{ diff --git a/go.mod b/go.mod index 2166108..e34b152 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,4 @@ module github.com/l0g1n/go-docx go 1.20 -require github.com/fumiama/imgsz v0.0.4 - -require golang.org/x/image v0.23.0 // indirect +require github.com/fumiama/imgsz v0.0.2 diff --git a/go.sum b/go.sum index 846ab56..ac04f3a 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,2 @@ -github.com/fumiama/imgsz v0.0.4 h1:Lsasu2hdSSFS+vnD+nvR1UkiRMK7hcpyYCC0FzgSMFI= -github.com/fumiama/imgsz v0.0.4/go.mod h1:bISOQVTlw9sRytPwe8ir7tAaEmyz9hSNj9n8mXMBG0E= -golang.org/x/image v0.23.0 h1:HseQ7c2OpPKTPVzNjG5fwJsOTCiiwS4QdsYi5XU6H68= -golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= +github.com/fumiama/imgsz v0.0.2 h1:fAkC0FnIscdKOXwAxlyw3EUba5NzxZdSxGaq3Uyfxak= +github.com/fumiama/imgsz v0.0.2/go.mod h1:dR71mI3I2O5u6+PCpd47M9TZptzP+39tRBcbdIkoqM4= From cf672f6983d4036cd6babd657cddb604c35ea7ee Mon Sep 17 00:00:00 2001 From: guoqiang Date: Sat, 21 Dec 2024 21:18:10 +0800 Subject: [PATCH 06/16] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 +++ .idea/go-docx.iml | 9 ++++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 +++ apirun.go | 8 +++ cmd/main/main.go | 50 ++++++++++++++++++ structpara.go | 2 + structsect.go | 132 ++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 223 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/go-docx.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/go-docx.iml b/.idea/go-docx.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/go-docx.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..3645359 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/apirun.go b/apirun.go index d302a06..99ef3fd 100644 --- a/apirun.go +++ b/apirun.go @@ -44,6 +44,14 @@ func (r *Run) SizeCs(size string) *Run { return r } +// Spacing allows to set run spacing +func (r *Run) Spacing(line int) *Run { + r.RunProperties.Spacing = &Spacing{ + Line: line, + } + return r +} + // Shade allows to set run shade func (r *Run) Shade(val, color, fill string) *Run { r.RunProperties.Shade = &Shade{ diff --git a/cmd/main/main.go b/cmd/main/main.go index 0d060ef..aaaf0b8 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -34,6 +34,56 @@ import ( ) func main() { + readFile, err := os.Open("/Users/gq/GolandProjects/docx-genert/data/template.docx") + if err != nil { + panic(err) + } + fileinfo, err := readFile.Stat() + if err != nil { + panic(err) + } + size := fileinfo.Size() + doc, err := docx.Parse(readFile, size) + if err != nil { + panic(err) + } + fmt.Println("Plain text:") + for _, it := range doc.Document.Body.Items { + switch it.(type) { + case *docx.Paragraph: // printable + pit := it.(*docx.Paragraph) + fmt.Printf("Paragraph: %v\n", it) + fmt.Printf("Paragraph pit: %v\n", pit.Style("size")) + case *docx.Table: + fmt.Printf("table: %v\n", it) + } + } + + //w := docx.New().WithDefaultTheme() + //// add new paragraph + //para1 := w.AddParagraph().Justification("center") + //// add text + //para1.AddText("中投证券股民个人信息泄露事件").Font("SimHei", "SimHei", "SimHei", "").Size("40").SizeCs("44") + //w.AddParagraph().Justification("center").AddText("").Font("SimHei", "SimHei", "SimHei", "").Size("40").SizeCs("44") + // + //w.AddParagraph().Style("ListParagraph").AddText("事件描述").Font("SimHei", "SimHei", "SimHei", "").Size("32").SizeCs("36") + + f, err := os.Create("bak.docx") + // save to file + if err != nil { + panic(err) + } + _, err = doc.WriteTo(f) + if err != nil { + panic(err) + } + err = f.Close() + if err != nil { + panic(err) + } +} + +func main2() { fileLocation := flag.String("f", "new-file.docx", "file location") analyzeOnly := flag.Bool("a", false, "analyze file only") clean := flag.Bool("c", false, "clean mode (keep text and picture only)") diff --git a/structpara.go b/structpara.go index 8d60d7b..9ea7657 100644 --- a/structpara.go +++ b/structpara.go @@ -22,6 +22,7 @@ package docx import ( "encoding/xml" + "fmt" "io" "reflect" "strings" @@ -57,6 +58,7 @@ func (p *ParagraphProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) e return err } if tt, ok := t.(xml.StartElement); ok { + fmt.Printf("tt.Name.Local: %s\n", tt.Name.Local) switch tt.Name.Local { case "tabs": var value Tabs diff --git a/structsect.go b/structsect.go index 3fac075..2298c88 100644 --- a/structsect.go +++ b/structsect.go @@ -28,6 +28,9 @@ import ( type SectPr struct { XMLName xml.Name `xml:"w:sectPr,omitempty"` // properties of the document, including paper size PgSz *PgSz `xml:"w:pgSz,omitempty"` + PgMar *PgMar `xml:"w:pgMar,omitempty"` + Cols *Cols `xml:"w:cols,omitempty"` + DocGrid *DocGrid `xml:"w:docGrid,omitempty"` } // PgSz show the paper size @@ -36,6 +39,25 @@ type PgSz struct { H int `xml:"w:h,attr"` // high of paper } +type PgMar struct { + Top int `xml:"w:top,attr"` + Left int `xml:"w:left,attr"` + Bottom int `xml:"w:bottom,attr"` + Right int `xml:"w:right,attr"` + Header int `xml:"w:header,attr"` + Footer int `xml:"w:footer,attr"` + Gutter int `xml:"w:gutter,attr"` +} + +type Cols struct { + Space int `xml:"w:space,attr"` +} + +type DocGrid struct { + Type string `xml:"w:type,attr"` + LinePitch int `xml:"w:linePitch,attr"` +} + // UnmarshalXML ... func (sect *SectPr) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error { for { @@ -55,6 +77,27 @@ func (sect *SectPr) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error { return err } sect.PgSz = &value + case "pgMar": + var value PgMar + err = d.DecodeElement(&value, &tt) + if err != nil && !strings.HasPrefix(err.Error(), "expected") { + return err + } + sect.PgMar = &value + case "cols": + var value Cols + err = d.DecodeElement(&value, &tt) + if err != nil && !strings.HasPrefix(err.Error(), "expected") { + return err + } + sect.Cols = &value + case "docGrid": + var value DocGrid + err = d.DecodeElement(&value, &tt) + if err != nil && !strings.HasPrefix(err.Error(), "expected") { + return err + } + sect.DocGrid = &value default: err = d.Skip() // skip unsupported tags if err != nil { @@ -90,3 +133,92 @@ func (pgsz *PgSz) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { _, err = d.Token() return err } + +func (pgmar *PgMar) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var err error + + for _, attr := range start.Attr { + switch attr.Name.Local { + case "top": + pgmar.Top, err = strconv.Atoi(attr.Value) + if err != nil { + return err + } + case "left": + pgmar.Left, err = strconv.Atoi(attr.Value) + if err != nil { + return err + } + case "bottom": + pgmar.Bottom, err = strconv.Atoi(attr.Value) + if err != nil { + return err + } + case "right": + pgmar.Right, err = strconv.Atoi(attr.Value) + if err != nil { + return err + } + case "header": + pgmar.Header, err = strconv.Atoi(attr.Value) + if err != nil { + return err + } + case "footer": + pgmar.Footer, err = strconv.Atoi(attr.Value) + if err != nil { + return err + } + case "gutter": + pgmar.Gutter, err = strconv.Atoi(attr.Value) + if err != nil { + return err + } + default: + // ignore other attributes now + } + } + // Consume the end element + _, err = d.Token() + return err +} + +func (cols *Cols) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var err error + + for _, attr := range start.Attr { + switch attr.Name.Local { + case "space": + cols.Space, err = strconv.Atoi(attr.Value) + if err != nil { + return err + } + default: + // ignore other attributes now + } + } + // Consume the end element + _, err = d.Token() + return err +} + +func (dg *DocGrid) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var err error + + for _, attr := range start.Attr { + switch attr.Name.Local { + case "linePitch": + dg.LinePitch, err = strconv.Atoi(attr.Value) + if err != nil { + return err + } + case "type": + dg.Type = attr.Value + default: + // ignore other attributes now + } + } + // Consume the end element + _, err = d.Token() + return err +} From b04675f57e6d41642d2add727ef87f4050b348f1 Mon Sep 17 00:00:00 2001 From: guoqiang Date: Sat, 21 Dec 2024 21:59:28 +0800 Subject: [PATCH 07/16] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=BA=8F?= =?UTF-8?q?=E5=8F=B7=E7=9A=84=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/main/main.go | 50 ------------------------------------------------ structpara.go | 8 ++++++++ structrun.go | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 50 deletions(-) diff --git a/cmd/main/main.go b/cmd/main/main.go index aaaf0b8..0d060ef 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -34,56 +34,6 @@ import ( ) func main() { - readFile, err := os.Open("/Users/gq/GolandProjects/docx-genert/data/template.docx") - if err != nil { - panic(err) - } - fileinfo, err := readFile.Stat() - if err != nil { - panic(err) - } - size := fileinfo.Size() - doc, err := docx.Parse(readFile, size) - if err != nil { - panic(err) - } - fmt.Println("Plain text:") - for _, it := range doc.Document.Body.Items { - switch it.(type) { - case *docx.Paragraph: // printable - pit := it.(*docx.Paragraph) - fmt.Printf("Paragraph: %v\n", it) - fmt.Printf("Paragraph pit: %v\n", pit.Style("size")) - case *docx.Table: - fmt.Printf("table: %v\n", it) - } - } - - //w := docx.New().WithDefaultTheme() - //// add new paragraph - //para1 := w.AddParagraph().Justification("center") - //// add text - //para1.AddText("中投证券股民个人信息泄露事件").Font("SimHei", "SimHei", "SimHei", "").Size("40").SizeCs("44") - //w.AddParagraph().Justification("center").AddText("").Font("SimHei", "SimHei", "SimHei", "").Size("40").SizeCs("44") - // - //w.AddParagraph().Style("ListParagraph").AddText("事件描述").Font("SimHei", "SimHei", "SimHei", "").Size("32").SizeCs("36") - - f, err := os.Create("bak.docx") - // save to file - if err != nil { - panic(err) - } - _, err = doc.WriteTo(f) - if err != nil { - panic(err) - } - err = f.Close() - if err != nil { - panic(err) - } -} - -func main2() { fileLocation := flag.String("f", "new-file.docx", "file location") analyzeOnly := flag.Bool("a", false, "analyze file only") clean := flag.Bool("c", false, "clean mode (keep text and picture only)") diff --git a/structpara.go b/structpara.go index 9ea7657..f80881b 100644 --- a/structpara.go +++ b/structpara.go @@ -33,6 +33,7 @@ type ParagraphProperties struct { XMLName xml.Name `xml:"w:pPr,omitempty"` Tabs *Tabs Spacing *Spacing + NumProperties *NumProperties Ind *Ind Justification *Justification Shade *Shade @@ -110,6 +111,13 @@ func (p *ParagraphProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) e p.RunProperties = &value case "pStyle": p.Style = &Style{Val: getAtt(tt.Attr, "val")} + case "numPr": + var value NumProperties + err = d.DecodeElement(&value, &tt) + if err != nil && !strings.HasPrefix(err.Error(), "expected") { + return err + } + p.NumProperties = &value case "textAlignment": p.TextAlignment = &TextAlignment{Val: getAtt(tt.Attr, "val")} case "adjustRightInd": diff --git a/structrun.go b/structrun.go index 1c97952..304a4e9 100644 --- a/structrun.go +++ b/structrun.go @@ -219,6 +219,55 @@ type RunProperties struct { Strike *Strike } +type NumProperties struct { + XMLName xml.Name `xml:"w:numPr,omitempty"` + NumId *NumId + Ilvl *Ilevel +} + +type NumId struct { + XMLName xml.Name `xml:"w:numId,omitempty"` + Val string `xml:"w:val,attr"` +} + +type Ilevel struct { + XMLName xml.Name `xml:"w:ilvl,omitempty"` + Val string `xml:"w:val,attr"` +} + +func (n *NumProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error { + for { + t, err := d.Token() + if err == io.EOF { + break + } + if err != nil { + return err + } + + if tt, ok := t.(xml.StartElement); ok { + switch tt.Name.Local { + case "numId": + var value NumId + value.Val = getAtt(tt.Attr, "val") + n.NumId = &value + case "ilvl": + var value Ilevel + value.Val = getAtt(tt.Attr, "val") + n.Ilvl = &value + default: + err = d.Skip() // skip unsupported tags + if err != nil { + return err + } + continue + } + } + } + + return nil +} + // UnmarshalXML ... func (r *RunProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error { for { From 3b41c42cadb298e27e6f7298c3f0ef9b300ea16f Mon Sep 17 00:00:00 2001 From: Rodrigo Stewart Date: Sun, 22 Dec 2024 00:34:43 +0800 Subject: [PATCH 08/16] Update main.go --- cmd/main/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/main/main.go b/cmd/main/main.go index 0d060ef..47ab230 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -30,7 +30,7 @@ import ( "strconv" "strings" - "github.com/l0g1n/go-docx" + "github.com/fumiama/go-docx" ) func main() { From 6628c1e91d0d1ee2eb9a3a9813fe6098f0424a4d Mon Sep 17 00:00:00 2001 From: Rodrigo Stewart Date: Sun, 22 Dec 2024 00:35:28 +0800 Subject: [PATCH 09/16] Update go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e34b152..fc3f48f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/l0g1n/go-docx +module github.com/fumiama/go-docx go 1.20 From 67c358ffb3b728f21c03c8748bef8aedf0169920 Mon Sep 17 00:00:00 2001 From: Rodrigo Stewart Date: Sun, 22 Dec 2024 00:35:54 +0800 Subject: [PATCH 10/16] Update structpara.go --- structpara.go | 1 - 1 file changed, 1 deletion(-) diff --git a/structpara.go b/structpara.go index f80881b..d0af8cb 100644 --- a/structpara.go +++ b/structpara.go @@ -59,7 +59,6 @@ func (p *ParagraphProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) e return err } if tt, ok := t.(xml.StartElement); ok { - fmt.Printf("tt.Name.Local: %s\n", tt.Name.Local) switch tt.Name.Local { case "tabs": var value Tabs From a77a00ab152de272c9a666ffe49bf4e1b15bf017 Mon Sep 17 00:00:00 2001 From: Rodrigo Stewart Date: Sun, 22 Dec 2024 00:38:12 +0800 Subject: [PATCH 11/16] Delete .idea/.gitignore --- .idea/.gitignore | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml From 3742406cda70f7c231efeb57464330dd92f6613b Mon Sep 17 00:00:00 2001 From: Rodrigo Stewart Date: Sun, 22 Dec 2024 00:39:12 +0800 Subject: [PATCH 12/16] Delete .idea/go-docx.iml --- .idea/go-docx.iml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .idea/go-docx.iml diff --git a/.idea/go-docx.iml b/.idea/go-docx.iml deleted file mode 100644 index 5e764c4..0000000 --- a/.idea/go-docx.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file From 499534b8987a81f599b1757ad8f88e621197196a Mon Sep 17 00:00:00 2001 From: Rodrigo Stewart Date: Sun, 22 Dec 2024 00:39:22 +0800 Subject: [PATCH 13/16] Delete .idea/vcs.xml --- .idea/vcs.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 8bbbf9a70ec437645a19087734d287ab49e9539b Mon Sep 17 00:00:00 2001 From: Rodrigo Stewart Date: Sun, 22 Dec 2024 00:39:34 +0800 Subject: [PATCH 14/16] Delete .idea/modules.xml --- .idea/modules.xml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .idea/modules.xml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 3645359..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From 1c25ffe3c8828eb177dcd8f0ecf37ace171fe3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 22 Dec 2024 16:21:55 +0800 Subject: [PATCH 15/16] Update structpara.go --- structpara.go | 1 - 1 file changed, 1 deletion(-) diff --git a/structpara.go b/structpara.go index d0af8cb..e80c600 100644 --- a/structpara.go +++ b/structpara.go @@ -22,7 +22,6 @@ package docx import ( "encoding/xml" - "fmt" "io" "reflect" "strings" From 9c7eb9fb7cda0bca06c5f95c90c56cfb40a82e46 Mon Sep 17 00:00:00 2001 From: guoqiang Date: Sun, 22 Dec 2024 21:38:37 +0800 Subject: [PATCH 16/16] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DFont=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apirun.go | 9 +++++---- cmd/main/main.go | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apirun.go b/apirun.go index e5d5128..c87f10a 100644 --- a/apirun.go +++ b/apirun.go @@ -100,11 +100,12 @@ func (r *Run) AddTab() *Run { } // Font sets the font of the run -func (r *Run) Font(ascii, hansi, hint string) *Run { +func (r *Run) Font(ascii, eastAsia, hansi, hint string) *Run { r.RunProperties.Fonts = &RunFonts{ - ASCII: ascii, - HAnsi: hansi, - Hint: hint, + ASCII: ascii, + EastAsia: eastAsia, + HAnsi: hansi, + Hint: hint, } return r } diff --git a/cmd/main/main.go b/cmd/main/main.go index 103cfaa..47ab230 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -66,11 +66,11 @@ func main() { para1.AddText("italic").Italic().AddTab() para1.AddText("underline").Underline("double").AddTab() para1.AddText("highlight").Highlight("yellow").AddTab() - para1.AddText("font").Font("Consolas", "", "cs").AddTab() + para1.AddText("font").Font("Consolas", "", "", "cs").AddTab() para2 := w.AddParagraph().Justification("end") para2.AddText("test all font attrs"). - Size("44").Color("ff0000").Font("Consolas", "", "cs"). + Size("44").Color("ff0000").Font("Consolas", "", "", "cs"). Shade("clear", "auto", "E7E6E6"). Bold().Italic().Underline("wave"). Highlight("yellow")