【问题标题】:Nodejs docx-merger plugin "Word found unreadable content"Nodejs docx-merger 插件“Word 发现不可读的内容”
【发布时间】:2020-01-22 05:58:53
【问题描述】:

我正在尝试通过 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." 消息。单击是时打开文档,但不是输出文件,只是一个缓冲区。

这是我的代码:

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

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

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

【问题讨论】:

    标签: javascript node.js merge docx


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2022-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多