I'm not sure of what's happening here. I have a perfectly functioning .docx as input file. But after parse it (didn't mody a thing) and write it as new file.. the output file gets corrupted)
func OpenDocx(path string) *docx.Docx {
readFile, err := os.Open(path)
util.Panic(err)
fileInfo, err := readFile.Stat()
util.Panic(err)
size := fileInfo.Size()
doc, err := docx.Parse(readFile, size)
util.Panic(err)
return doc
}
func WriteDocx(doc *docx.Docx, path string) {
f, err := os.Create(path)
util.Panic(err)
_, err = doc.WriteTo(f)
util.Panic(err)
err = f.Close()
util.Panic(err)
}
and somwhere in my main.go
...
...
doc := docxLib.OpenDocx(inputFile)
docxLib.WriteDocx(doc, "copy.docx")
...
...
when I try to open copy.docx in Word, I cannot because of corrupted file.
I'm not sure of what's happening here. I have a perfectly functioning .docx as input file. But after parse it (didn't mody a thing) and write it as new file.. the output file gets corrupted)
and somwhere in my main.go
when I try to open copy.docx in Word, I cannot because of corrupted file.