Releases RSS Feed
Compatibility : nodejs and browser

Summary (version 3.2.9) Buy slides module

This module makes it possible to create multiple slides with a loop in a pptx. For example, you could clone slides for each of your products. The whole order of the slides can be declared from the data.

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



You will need docxtemplater v3: npm install docxtemplater

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


There are two ways of using the slides module. Explicit, where the developper specifies which slides to repeat, and Tagging, where the template creator chooses which slides to repeat from the template itself by tagging slides with a specific tag.

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


If you use the explicit method, you write from the code which slides you want to repeat :

const SlidesModule = require("docxtemplater-slides-module");

const slidesModule = new SlidesModule();

const data = {
    slides: [
        { $slide: 1, name: "Franck", phone: "+665432131" },
        { $slide: 1, name: "Jim", phone: "+6234468468" },
        { $slide: 1, name: "Joe", phone: "+78788787" },
        { $slide: 1, name: "Hugh", phone: "03566456465" },
        { $slide: 3, title: "The Title" },
            $slide: 2,
                "Lorem ipsum dolor sit amet, consectetur adipisicing elit...",

const doc = new Docxtemplater(zip, { modules: [slidesModule] });

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

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

And in your template, write :


{name} {phone}

Slide 2


Slide 3


This means that : you want to use the \$slide 1 from the template to generate 4 slides in your output document, then you want to use the slide 3 of your template and put it at position 5 in your output, and use the slide 2 of your template to put it at position 6 in your output. All generated slides also have different data (name, phone, title and content in this example).

With the explicit method, it is possible to reorder slides, duplicate them or remove them.

Usage (browser)

    <script src="node_modules/docxtemplater/build/docxtemplater.js"></script>
    <script src="node_modules/pizzip/dist/pizzip.js"></script>
    <script src="node_modules/pizzip/vendor/FileSaver.js"></script>
    <script src="node_modules/pizzip/dist/pizzip-utils.js"></script>
    <script src="build/slides-module.js"></script>
        PizZipUtils.getBinaryContent("demo_template.pptx", function (
        ) {
            if (error) {
            var slidesModule = new DocxtemplaterSlidesModule();

            var zip = new PizZip(content);
            var doc = new docxtemplater(zip, { modules: [slidesModule] });

                date: "02-25-2018",
                title: "My presentation",
                description: "A wonderful card",
                users: [
                    { name: "John Doe" },
                    { name: "Jane Zang" },
                    { name: "Mary Bar" },

            var out = doc.getZip().generate({
                type: "blob",
            saveAs(out, "generated.pptx");


In that case, it is the template creator that will tag certain slides to express that some slides must be repeated or removed depending on conditions or loops.

To tag a slide with the text "users", you write {:users} anywher on that slide. Those tags will be removed after generation by docxtemplater.

All slides that are untagged are shown exactly once.

All slides that are tagged are shown depending on the value of the tag.

If the value is an array, the slide is repeated for each element in an array.

If the value is false or falsy, the slide is removed.

If the value is true or truthy, the slide is shown once.

const SlidesModule = require("docxtemplater-slides-module");

const slidesModule = new SlidesModule();

const data = {
    mainTitle: "My title",
    users: [
        { name: "Franck", phone: "+665432131" },
        { name: "Jim", phone: "+6234468468" },
        { name: "Joe", phone: "+78788787" },
        { name: "Hugh", phone: "03566456465" },
    foo: "bar",

const doc = new Docxtemplater(zip, { modules: [slidesModule] });

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

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

And in your template, write :



{name} {phone}

In this case, the first slide will be shown once, and the second slide will be repeated 4 times (since users is an array of 4 elements).

With the tagging module, it is possible to remove slides conditionnally. To do that, you have to tag the slide with the text {:isShown} and set {isShown:false} in your setData() call.

Special Features

Everything that is outside of the "slides" key is automatically accessible from all templated slides.

You can use the special variables {$count} and {$index} in your template to get the index of the current slide, and the total count of the slides (in the expected output).


Is it possible to manipulate slides within a presentation ?

Yes, either with the explicit method or the tagging method explained above.

Is it possible to reorder slides ?

Yes, with the explicit method that is possible. It is however not possible with the tagging method, since tagging will keep the same order of the slides as in the template document.

Is it possible to combine two presentations from two pptx files ?

No, this is currently not possible, but could be implemented, contact me if you're interested.

Is it possible to get a JSON representation of the slides ?

Yes, you can do the following to get a JSON data structure :

var zip = new PizZip(content);
const SlidesModule = require("docxtemplater-slides-module");
const slidesModule = new SlidesModule();
var doc = new Docxtemplater(zip, { modules: [slidesModule] });
    require("util").inspect(this.doc.compiled, { showHidden: true, depth: 2 })

it gives you following JSON object :

    "ppt/slides/slide1.xml": {
        "content": "<?xml......"
    "ppt/slides/slide2.xml": {
        "content": "<?xml......"



Bugfix use real scopeManager for getting value of {:foo | bar} to be calling parser with the same parameters as when using the parser.

If you are using the code with following parser, you will have the error "Cannot read property scopeList of undefined", because the variable "context" was not passed.

return {
    get: function (scope, context) {
        let obj = {};
        const scopeList = context.scopeList;
        const num = context.num;
        for (let i = 0, len = num + 1; i < len; i++) {
            obj = merge(obj, scopeList[i]);
        return expr(scope, obj);


Run parser passed to Docxtemplater options object for tags in slides explicit module.

For example, it is now possible to use angular expressions in slide tags, for example :

{:users | ifActive} if you define the expressions.filters.ifActive


A bug was introduced in version 3.2.2 which would, after 1000s of generations, trigger a Maximum call stack size exceeded. This release fixes the bug.


Bugfix do not fail with Cannot read property 'setAttribute' of undefined at js/slidesrepo.js:19:2 when having a slide note without a reference to the slide.


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


Bugfix to work together with pptx-subtemplate module, previous versions could produce corrupt documents


Make it possible to use together with pptx-subtemplate module


Add templating on notes of each slides


Bugfix when the targets of the presentation.xml are absolute path instead of relative paths


  • Add support for chunking (it is used currently only in the table module for the "grid" feature.


  • Update browser build to use XMLSerializer instead of xmldom

  • Use requiredAPIVersion


  • Move docxtemplater from devDependencies to dependencies

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


Fix bug of notes being "moved" from one slide to the other during generation


Include notes for each of the rendered slide


Fail properly when a slide does not exist


Add support for boolean values true/false and objects in loops


Bugfix : SlideMasters are now correctly templated


Bugfix when having notes in pptx


Bugfix : Slide 10 and following slides are no longer removed


Add possibility to tag slides for repetition with {:users}


Add compatibility with image-module


Exported files are now ES5


Bugfix : Slides module doesn't throw an error anymore when templating docx files


Initial release

Edgar Hipp

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