Demo Readme Changelog Buy footnotes module

Summary (version 3.0.1)

This module exposes a tag to add a footnote to the document

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

Demo

Input Output
Data Code
{
    "foot": "\"Albert Einstein – Biography\". Nobel Foundation. Archived from the original on 6 March 2007. Retrieved 7 March 2007."
}
const doc = new Docxtemplater();
const inputZip = new JSZip(docX);
doc.loadZip(inputZip)
	.setData(data);

const footnoteModule = new FootnoteModule();
doc.attachModule(footnoteModule);
const output = doc.render().getZip();

README

Installation:

You will need docxtemplater npm install docxtemplater

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

Usage

Your docx should contain the text: {:footnote foot}

var FootnoteModule=require('docxtemplater-footnote-module')

var footnoteModule=new FootnoteModule(opts);

var zip = new JSZip(content);
var docx=new Docxtemplater()
    .attachModule(footnoteModule)
    .loadZip(zip)
    .setData({foot:'The text of the footnote'})
    .render();

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

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

Testing

You can test that everything works fine using the command npm test. This will also create some docx files under the root directory that you can open to check if the generation was correct.

Building in the browser

You can build a release for the browser with the following commands

npm install
npm run preversion

You will have build/footnotemodule.js.

CHANGELOG

3.0.1

It now works even if some footnotes already exist (if word/footnotes.xml exists)

3.0.0

Initial release.

Edgar Hipp

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