繁体   English   中英

Nodejs docx-merger 插件“Word 发现不可读的内容”

[英]Nodejs docx-merger plugin “Word found unreadable content”

我正在尝试通过docx-merger库合并 docx 文件。 一切都很好,除了 Microsoft Word 的"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." 信息。 单击“是”时会打开文档,但不会打开 output 文件,只是一个缓冲区。

这是我的代码:

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
    });
    }});
});

我在这里尝试合并input文件夹中的docx文件。

它合并了所有这些,但没有此消息我无法打开文件。

Header 和页脚部分是导致此问题的原因。 尝试删除文档中的 header 和页脚部分。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM