generate-docx
Generates .docx from template and data
Returns a Buffer or saves the generated file if given path and filename.
Example save file
Promises
const generateDocx = const options = template: filePath: 'test/data/testdoc.docx' data: title: 'This is the title' description: 'Description is good' body: 'My body is my temple' save: filePath: 'test/data/savedfile.docx'
Callback
const generateDocx = const options = template: filePath: 'test/data/testdoc.docx' data: title: 'This is the title' description: 'Description is good' body: 'My body is my temple' save: filePath: 'test/data/savedfile.docx'
Example return buffer
Promises
const writeFileSync = const generateDocx = const options = template: filePath: 'test/data/testdoc.docx' data: title: 'This is the title' description: 'Description is good' body: 'My body is my temple'
Callback
const writeFileSync = const generateDocx = const options = template: filePath: 'test/data/testdoc.docx' data: title: 'This is the title' description: 'Description is good' body: 'My body is my temple'
Options
If you need to pass an option object to configure docxtemplater you can do using templateOptions
.
For example you can configure docxtemplater to parse \n
as a linebreak in the document
const options = template: filePath: 'test/data/testdoc.docx' data: title: 'This is the title' description: 'Description is good' body: 'My body is \n my temple' templateOptions: linebreaks: true save: filePath: 'test/data/savedfile.docx'