1

How to use html-docx-js in node.js .

I have refered the npm site (https://www.npmjs.com/package/html-docx-js) for this. Below is the code

var converted = htmlDocx.asBlob(content);
saveAs(converted, 'test.docx');

But here is the problem, the saveAs function is missing in the tutorial.

I have downloaded filesaver.js on the client side i Iave implemented this and it works fine. But I want complete code in node.js running which it will convert my html content and will download a word file in client machine.

Looking forward for some help. Regards,

Bikram Nayak.

edi9999
  • 19,701
  • 13
  • 88
  • 127
Bikram Nayak
  • 21
  • 1
  • 6
  • 2
    What have you tried so far? Please remove your email and add the smallest possible section of your code which you are having a problem with – Will Barnwell Jul 12 '17 at 17:41

1 Answers1

0
    var HtmlDocx = require('html-docx-js');
    var fs = require('fs');
    var html = 'fasfasfasdfsfsdfsf';

    var docx = HtmlDocx.asBlob(html);
    fs.writeFile('helloworld3.docx',docx, function (err){
       if (err) return console.log(err);
       console.log('done');
    });