Comments (5)
If your curious on the fix, i tried this and it worked perfectly for the use case
https://github.com/nguyenthenguyen/docx
package main
import (
"github.com/nguyenthenguyen/docx"
)
func main() {
r, err := docx.ReadDocxFile("./Test.docx")
if err != nil {
panic(err)
}
docx1 := r.Editable()
// Replace like https://golang.org/pkg/strings/#Replace
docx1.Replace("Test", "Test-BG", -1)
docx1.Replace("old_1_2", "new_1_2", -1)
docx1.ReplaceHeader("out with the old", "in with the new")
docx1.ReplaceFooter("Change This Footer", "new footer")
docx1.WriteToFile("./Test-out.docx")
r.Close()
}
from unioffice.
@joeblew99 That package unpacks the XML and does a search and replace. This one fully parses the documents to allow more advanced editing. The problem with this one is we aren't handling the image filename correctly. In the document it's 'word/media/image2.png', even though it's the only image and when saving we are writing it back out as 'word/media/image1.png' without changing the relationship file to reflect the new name. It should be a straight forward fix, we handle the renames for other types but skipped it for images so far.
from unioffice.
@joeblew99 I rolled a quick fix into a branch I was about to merge in. I'l add a test for it later, but this should fix your issue. Feel free to re-open if you still run any problems.
from unioffice.
@joeblew99 Also, do you mind if I check your test.docx in and use it as a test file?
from unioffice.
from unioffice.
Related Issues (20)
- Could not extract information (text, table, image, ...etc) from a .doc file HOT 1
- License error text is confusing HOT 6
- Is this still Open Source software? HOT 1
- Cannot insert table correctly HOT 3
- Feature request: Animations for PowerPoint HOT 1
- nil pointer when convert docx to pdf HOT 9
- Runtime error extracting text from Word document HOT 3
- No text in document after converting a Word document to PDF HOT 3
- How to split a run and/or paragraph while preserving styling HOT 3
- No text extracted from PowerPoint file HOT 2
- how to get the real content contained in the specified bookmark HOT 2
- AppProperties.Pages() doesn't always return the correct number of pages HOT 2
- Convert `.docx` to `.pdf` misses images HOT 2
- How to get the page size for a Word doc? HOT 7
- is there support for adding a comment to a word doc? HOT 1
- Unit tests? HOT 2
- Why do proofreading errors occur HOT 5
- panic: runtime error: index out of range [0] with length 0 while converting docx to pdf HOT 1
- May I ask if there is an implementation for inserting chart elements into pptx? HOT 1
- How to insert a table at a specified location in a word document HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unioffice.