Demo Readme Changelog Buy word-run module Releases RSS

Summary (version 3.0.1)

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.

README

WRun module for docxtemplater.

Installation:

You will need docxtemplater v3: npm install docxtemplater

Install this module with npm install --save "$url"

Usage

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);

Building

You can build the es6 into js by running npm run compile

Testing

npm test

CHANGELOG

3.0.1

Make it possible to use different prefix than "r@"

3.0.0

Initial release

Edgar Hipp

I'm the creator of docxtemplater. I work on making docxtemplater great since 2013.