You are currently offline, serving cached version
10 December 2024 : If you are using angular-expressions to parse expressions such as {user.name}, {#users.length > 10}, please upgrade asap to angular-expressions@1.4.3 for security reasons : View Github issue

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 doc = new Docxtemplater(zip, {
    modules: [new WRunModule()],
});
doc.render({
    wrun: `<w:r>
            <w:rPr>
                <w:b/>
                <w:lang w:val="en-GB"/>
            </w:rPr>
            <w:t>bold</w:t>
         </w:r>`,
});

const buffer = doc.getZip().generate({
    type: "nodebuffer",
    compression: "DEFLATE",
});

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

After installing the module, you can use a working demo by running node sample.js.

CHANGELOG

3.2.5

Make it possible to use prefix from the constructor

3.2.4

Add typescript typings to be able to change the module prefix

3.2.3

Upgrade module to use NodeNext moduleResolution setting. See explanation here

3.2.2

Set module.priority in order to have no more issues related to module ordering

3.2.1

Add module.clone() internal to make module work well with subsegment module

3.2.0

Make module compatible with docxtemplater@3.28.0. Please make sure to update docxtemplater to 3.28.0 at the same time you update this module. The internal change made is the use of the new matchers API which fixes bugs that were triggered depending on the order of the modules that are attached to the instance. Now the order of the modules should not matter as expected.

3.1.4

Use @xmldom/xmldom instead of xmldom, see this github issue

3.1.3

Generate files in built with correct filename In previous versions, the filename was always build/docxtemplater.js. Now the filename is build/word-run-module.js The .min.js file is also created now.

3.1.2

Add typescript definitions for public API

3.1.1

Bugfix when using docxtemplater 3.19.6 or newer

3.1.0

Add support for pptx filetype

3.0.7

Declare supportedFileTypes, which allows to use this module with the new docxtemplater constructor which was introduced in docxtemplater 3.17.

3.0.6

Bugfix when having no data

3.0.5

  • Update browser build to use XMLSerializer instead of xmldom

  • Use requiredAPIVersion

3.0.4

  • Move docxtemplater from devDependencies to dependencies

Explanation : On some versions of npm (notably 5.8.0), when having a package containing docxtemplater-word-run-module, the installation will generate a tree of node_modules that puts the module on a level where it has no access to docxtemplater. By explicitly asking it as a dependency, this issue is avoided.

3.0.3

  • Make module compatible with docxtemplater version 3.5 and below.

Explanation : Recently, the scopemananger API (internal API) has changed, this new version of the word-run module makes the module work with both versions newer than 3.6 and older than 3.6 of docxtemplater.

3.0.2

Add meta context argument to custom parser with information about the tag for each types of tags

3.0.1

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

3.0.0

Initial release

Talk with sales Contact us