You are currently offline, serving cached version


This module exposes a tag to replace a qrCode image in your template into any kind of image. The qrcode of the pages are parsed, then they are replaced with with the getImage function.

Docxtemplater will keep all the styling that you put on your qrcode (shades, effects, size, …).

The following :

Qrcode containing the static text {company.logo}

with following data :

    company: {
        logo: "acme.png",

Will render :

Acme logo
Acme logo


Your docx should contain an image that contains a qrcode text. You can use The Qrcode Generator in Text mode to generate your qrcodes (you need to click on the "free text" button first).

The file has to be a JPG/BMP/PNG file, since the image parser that we use can only read these formats (TIFF format is not handled). If your qrcode is not replaced, it is possible that it is because your image was saved as TIFF.

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


The qrcode module takes as an argument the getImage function, which should return the image depending on the resolved tag value.

const QrCodeModule = require("docxtemplater-qrcode-module");
const fs = require("fs");
const path = require("path");

const qrCodeModule = new QrCodeModule({
    getImage(value) {
        return fs.readFileSync(
            path.resolve(__dirname, "..", "images", value)
const doc = new Docxtemplater(zip, { modules: [qrCodeModule] });

The qrcode module constructor takes as an argument the autoDelimiters boolean (false by default). When autoDelimiters is set to true, instead of encoding "{image}" in your qrcode, you can just encode "image".

Async support

It is possible to get images asynchronously by returning a Promise in the getImage function and use the docxtemplater async api.

Webpack support

To make this module work well in webpack, you have to declare the following in your webpack.config.js (in the module.exports):

module.exports = {
    // ...
    plugins: [
        new webpack.DefinePlugin({
            "process.env": {
                ENV: JSON.stringify("BROWSER"),



Bugfix to work correctly with image-module version 3.28.2


Upgrade to use @jimp/custom to avoid pulling many unused dependencies


Upgrade module to use NodeNext moduleResolution setting. See explanation here


When using the inspectModule to getAllTags, avoid showing "undefined" key for qrcode tags.

Requires docxtemplater 3.42.1 or higher


Allow to insert emf images (use correct content-type of image/x-emf)


Fix bug when using renderAsync and parser compilation fails : the error should now be shown inside a multierror. To to this, we know use sm.getValueAsync in resolve instead of sm.getValue


Bugfix to set or get xml attributes correctly, even when using tabs instead of spaces in tags attributes


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


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


Add endLindex to qrcode part.

Fixes issue of disappearing images when used together with subsegment module


This version requires docxtemplater@3.35.0 or more.

Bugfix : When having an image inside a textbox that also had some text, the tags that are in the textbox were not correctly replaced.

This happened both if the image was a real qrcode or if it was a standard image tag.

The bug meant that the tags were replaced like this :

{first_name} {last_name}

With the data : doc.render({first_name: "John", last_name: "Doe"});

Was replaced by this :

first_name last_name


Rename loader function to getImage

The loader function can no more be used now.


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


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


Add typescript definitions for public API


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


  • Bugfix for slide-module + Performance : Analyze only files that can contain images. WIth slides-module v3.2.2, and with qrcode-module v3.2.1 or below, some unintended "slideNotes.rels.xml" were created


  • Update browser build to use XMLSerializer instead of xmldom

  • Use requiredAPIVersion


  • Update jsqr to 1.1.1

  • Fix bug docPrId duplicated


  • Move docxtemplater from devDependencies to dependencies

Explanation : On some versions of npm (notably 5.8.0), when having a package containing docxtemplater-qrcode-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.


  • Make module compatible with docxtemplater version 3.5 and below.

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

  • Add autoDelimiters option


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


  • Add async support (by returning a Promise in the getImage function).


Accept getImage as option to have similar API as the image module.

loader is still accepted, but will be deprecated in future major version


  • Correctly handle failed qrcode parsing


  • Replace qrcode-engine to handle more "versions" of the qrcode specification


  • Do not fail if one image cannot be parsed (EMF files for example)


  • Make it possible to have object in data values, for example :

the qrcode could be decoded to {parameters} and the data is :

    "parameters": { "path": "path_to_file.png" }

and the loader function will now be called with :

loader({"path": "path_to_file.png"})

before this release, it was called with "" by mistake.


  • Add browserified and minified bundles


  • Use Jimp dependency to allow installation without Python


  • Bugfix when qrCode empty
  • Works with slides modules
  • Works with pptx
  • Works with multiple smartarts


Initial release

Talk with sales Contact us