1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-09 01:30:25 +08:00

add more attrs

This commit is contained in:
源文雨
2023-03-10 00:43:36 +08:00
parent cf061a29e4
commit 45efdb3378
6 changed files with 154 additions and 8 deletions

View File

@@ -38,6 +38,7 @@ func main() {
clean := flag.Bool("c", false, "clean mode (keep text and picture only)")
unm := flag.Bool("u", false, "lease unmarshalled file")
splitre := flag.String("s", "", "split file into many docxs by matching regex")
droppp := flag.Bool("p", false, "drop all paragraph properties")
flag.Parse()
var w *docx.Docx
if !*analyzeOnly {
@@ -180,6 +181,22 @@ func main() {
if *clean {
doc.Document.Body.DropDrawingOf("NilPicture")
}
if *droppp {
for _, it := range doc.Document.Body.Items {
switch o := it.(type) {
case *docx.Paragraph: // printable
o.Properties = nil
case *docx.Table: // printable
for _, tr := range o.TableRows {
for _, tc := range tr.TableCells {
for _, p := range tc.Paragraphs {
p.Properties = nil
}
}
}
}
}
}
if *unm {
i := strings.LastIndex(*fileLocation, "/")
name := (*fileLocation)[:i+1] + "unmarshal_" + (*fileLocation)[i+1:]