Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 615 Bytes

async.rst

File metadata and controls

23 lines (18 loc) · 615 Bytes
.. index::
   single: Async

Asynchronous generation

You can have promises in your data.

var doc = new Docxtemplater();
doc.loadZip(zip);
doc.setOptions(options);
doc.compile(); // You need to compile your document first.
doc.resolveData({user: new Promise(resolve) { setTimeout(()=> resolve('John'), 1000)}})
   .then(function() {
       doc.render();
       var buf = doc.getZip()
           .generate({type: 'nodebuffer'});
       fs.writeFileSync(path.resolve(__dirname, 'output.docx'), buf);
   });