mirror of
https://github.com/fumiama/go-docx.git
synced 2026-06-10 02:00:24 +08:00
feat: add drawing inline marshal
This commit is contained in:
@@ -5,8 +5,6 @@ import (
|
||||
"archive/zip"
|
||||
"encoding/xml"
|
||||
"io"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
// This receives a zip file (word documents are a zip with multiple xml inside)
|
||||
@@ -36,10 +34,8 @@ func unpack(zipReader *zip.Reader) (docx *Docx, err error) {
|
||||
func processDoc(file *zip.File, doc *Document) error {
|
||||
filebytes, err := readZipFile(file)
|
||||
if err != nil {
|
||||
glog.Errorln("Error reading from internal zip file")
|
||||
return err
|
||||
}
|
||||
glog.V(0).Infoln("Doc:", string(filebytes))
|
||||
|
||||
doc.XMLW = XMLNS_W
|
||||
doc.XMLR = XMLNS_R
|
||||
@@ -47,10 +43,8 @@ func processDoc(file *zip.File, doc *Document) error {
|
||||
doc.XMLName.Local = "document"
|
||||
err = xml.Unmarshal(filebytes, doc)
|
||||
if err != nil {
|
||||
glog.Errorln("Error unmarshalling doc", string(filebytes))
|
||||
return err
|
||||
}
|
||||
glog.V(0).Infoln("Paragraph", doc.Body.Paragraphs)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -58,15 +52,12 @@ func processDoc(file *zip.File, doc *Document) error {
|
||||
func processRelations(file *zip.File, rels *Relationships) error {
|
||||
filebytes, err := readZipFile(file)
|
||||
if err != nil {
|
||||
glog.Errorln("Error reading from internal zip file")
|
||||
return err
|
||||
}
|
||||
glog.V(0).Infoln("Relations:", string(filebytes))
|
||||
|
||||
rels.Xmlns = XMLNS_R
|
||||
err = xml.Unmarshal(filebytes, rels)
|
||||
if err != nil {
|
||||
glog.Errorln("Error unmarshalling relationships")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user