Documentation and demo for module word-run

Summary

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

Have any questions ? Contact us at contact@javascript-ninja.fr


Subscribe to our newsletter and keep up to date on the changes done in docxtemplater.

Edgar Hipp

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