This module exposes a tag to insert raw runs (<w:r>) inside the document. This makes it possible to include styled text without having to remove the enclosing paragraph like in the {@rawXml} tag.
This module is available as part of the docxtemplater PRO plan.
WRun module for docxtemplater.
You will need docxtemplater v3: npm install docxtemplater
Install this module with npm install --save "$url"
Your docx should contain the text: {r@wrun}
The following example will render some bold text
const fs = require('fs');
const WRunModule = require('docxtemplater-wrun-module');
const wrunModule = new WRunModule();
const wrun = "<w:r>" +
"<w:rPr>" +
"<w:b/>" +
"<w:lang w:val="en-GB"/>" +
"</w:rPr>" +
"<w:t>bold</w:t>" +
"</w:r>";
const docx = new DocxGen()
.attachModule(wrunModule)
.loadZip(zip)
.setData({
wrun:wrun
})
.render();
const buffer = docx
.getZip()
.generate({type:"nodebuffer", compression: "DEFLATE"});
fs.writeFile("test.docx", buffer);
You can build the es6 into js by running npm run compile
npm test