-
-
Notifications
You must be signed in to change notification settings - Fork 498
Exporting
Dolan edited this page Dec 6, 2017
·
3 revisions
I used the express exporter in my website. It's very useful, and is the preferred way if you want to make a downloadable file for a visitor. it is much better than generating a physical file on the server, and then passing a download link to that file.
Simply use the exporter, and pass in the necessary parameters:
var docx = require('docx');
var doc = new docx.Document();
var exporter = new docx.ExpressPacker(doc, res);
exporter.pack('My Document');
where res
is the response object obtained through the Express router. It is that simple. The file will begin downloading in the browser.
var docx = require('docx');
var doc = new docx.Document();
var exporter = new docx.LocalPacker(doc);
exporter.pack('My Document');
You can export your word document as a PDF file like so:
var exporter = new docx.LocalPacker(doc);
exporter.packPdf('My Document');
// Express
var exporter = new docx.ExpressPacker(doc, res);
exporter.packPdf('My Document');
It is on the bucket list. It has been requested by a few, and work is already on it