Comments (4)
Thank you very much!
from go-docx.
Could you please be a bit more elaborate on what you are trying to do?
from go-docx.
wordDocx, docxErr := docx.Open(docxPath)
if docxErr != nil {
ctx.StopWithStatus(500)
return
}
replaceMap := docx.PlaceholderMap{
"year": "2024",
"month": "04",
"day": "03",
}
// replace the keys with values from replaceMap
docxErr = wordDocx.ReplaceAll(replaceMap)
if docxErr != nil {
ctx.StopWithStatus(500)
return
}
ctx.Header("Content-Type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
ctx.Header("Content-Disposition", "attachment; filename=example.docx")
ctx.Write([]byte)//iris.go I need to type directly back to the file stream, not write to the file
from go-docx.
Ahh, i see. Thanks for elaborating.
This should already be possible. You can use document.Write for that. Something like this should work:
// ...
out := []bytes{}
buf := bytes.NewBuffer(out)
err = wordDocx.Write(buf)
// now you can continue work with just the byte slice of the rendered document
ctx.Write(buf.Bytes())
from go-docx.
Related Issues (20)
- Configurable delimiters
- Inserting of new runs / paragraphs / docx-files HOT 1
- Documents corrupted HOT 1
- table merge and table foreach HOT 1
- 能否支持if 和表格循环? HOT 3
- Many paragraphs. HOT 1
- Is it possible to avoid line break collapse? HOT 2
- PlaceholderMap (or Word) does not adhere to '\n' character HOT 8
- Support for dynamically parametrized variables HOT 1
- Replace checkbox symbol in Word docx HOT 3
- I hope that this library will be able to replace images in the future. HOT 4
- how we can change delimiter? HOT 2
- 有计划支持表格 表格合并单元格吗? HOT 1
- function to get all placeholders in file HOT 1
- Error if placeholder has leading or tailing whitespace(-s) inside of delimiters
- v0.4.6 can not replace with ampersand `&`. HOT 1
- Document tag truncated HOT 3
- [FEATURE REQUEST] - Support for control statements like condition, loop HOT 2
- [FEATURE REQUEST] - Support for dynamic table templates HOT 1
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 go-docx.