Summary (version 3.0.0)
Demo Readme Changelog Buy this module

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.

Demo

Input Output
Data Code
{
    companyDescription: `
        <w:r><w:rPr><w:i/><w:lang w:val="en-GB"/></w:rPr><w:t xml:space="preserve">Acme </w:t></w:r>
        <w:r><w:rPr><w:lang w:val="en-GB"/></w:rPr><w:t xml:space="preserve">company is </w:t></w:r>
        <w:r><w:rPr><w:b/><w:lang w:val="en-GB"/></w:rPr><w:t xml:space="preserve">amazing</w:t></w:r>
        `
        ,
    description1: `
        <w:r><w:rPr><w:i/><w:lang w:val="en-GB"/></w:rPr><w:t xml:space="preserve">italic, </w:t></w:r>
        <w:r><w:rPr><w:b/><w:lang w:val="en-GB"/></w:rPr><w:t xml:space="preserve">bold, </w:t></w:r>
        <w:r><w:rPr><w:color w:val="800000"/><w:lang w:val="en-GB"/></w:rPr><w:t xml:space="preserve">color</w:t></w:r>
        `,
    description2: `
        <w:r><w:rPr><w:u w:val="single"/><w:lang w:val="en-GB"/></w:rPr><w:t xml:space="preserve">Underline, </w:t></w:r>
        <w:r><w:rPr><w:strike/><w:lang w:val="en-GB"/></w:rPr><w:t xml:space="preserve">strike, </w:t></w:r>
        <w:r><w:rPr><w:vertAlign w:val="subscript"/><w:lang w:val="en-GB"/></w:rPr><w:t xml:space="preserve">subscript</w:t></w:r>
    `,
    price1: 2000,
    price2: 5000
}
const doc = new Docxtemplater();
const inputZip = new JSZip(docX);
doc.loadZip(inputZip)
	.setData({data});
const wordRunModule = new WordRunModule();
doc.attachModule(wordRunModule);
const output = doc.render().getZip();

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

fs.writeFile("test.docx", buffer);

Building

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

Testing

npm test

CHANGELOG

3.0.0

Initial release

You can buy only this module by using following link : Buy this module

Edgar Hipp

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