2017-07-12 157 views
0

如何在node.js中使用html-docx-js使用node.js將html內容寫入word並下載到用戶機器

我已經提到npm網站(https://www.npmjs.com/package/html-docx-js)。以下是代碼

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

但是,這裏是問題,教程中缺少saveAs函數。

我已經下載了filesaver.js在客戶端我實現了這個,它工作正常。但我想在node.js運行它的完整代碼,它將轉換我的html內容,並將在客戶端機器下載一個word文件。

期待一些幫助。 Regards,

Bikram Nayak。

+2

你到目前爲止試過了什麼?請刪除您的電子郵件,並添加您遇到問題的代碼中可能的最小部分 –

回答

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'); 
    }); 
相關問題