问题
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