Demo Readme Changelog Buy qrcode module Releases RSS

Summary (version 3.1.2)

This module makes it possible to replace an image by an other image

This module is available as part of the docxtemplater ENTREPRISE plan.


Input Output
Data Code
    "image": "examples/firefox.png"
const fs = require("fs");
const doc = new Docxtemplater();
const inputZip = new JSZip(docX);
const qrCodeModule = new QrCodeModule({
	loader: function(tag) {
		return fs.readFileSync(path.resolve(__dirname, "..", "images", tag));
qrCodeModule.decodeImages(inputZip, () => {
	const output = doc.render().getZip();


QrCode Module

This module exposes a tag to include qrCode. 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, …).


You will need docxtemplater v3: npm install docxtemplater

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


Your docx should contain an image that contains a qrcode text. You can use a in Text mode to generate your qrcodes.

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.

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

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


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


npm test



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

Edgar Hipp

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