Nodejs docx-merger plugin “Word found unreadable content”

ぐ巨炮叔叔 提交于 2020-01-06 08:16:07

问题


I'm trying to merge docx files via docx-merger library. Everything is good, except of Microsoft Word's "Word found unreadable content in output.docx. Do you want to recover the contents of this document? If you trust the source of this document, click Yes." message. It opens the document when click to yes, but not the output file, just a buffer.

Here is my code:

const docxMerger = require('docx-merger');
fs.readdir('input/', (err, bufferFiles) => {
    var bufferFilesArr = [];
    bufferFiles.forEach(bufferFile => {
    var file = fs.readFileSync(path.resolve('app/temps/buffer',bufferFile), 'binary');
    bufferFilesArr.push(file);
    });
    var mergedDocx = new docxMerger({}, bufferFilesArr);

    mergedDocx.save('nodebuffer', function(data){{
    fs.writeFileSync(path.resolve('output','output.docx'), data, 'utf8',function(err){
        //callback
    });
    }});
});

I'm trying here to merge docx files which are in the input folder.

It merges all of them, but I can not open file without this message.

来源:https://stackoverflow.com/questions/58040848/nodejs-docx-merger-plugin-word-found-unreadable-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!