Nodejs docx合并插件"Word发现不可读内容" [英] Nodejs docx-merger plugin "Word found unreadable content"

查看:145
本文介绍了Nodejs docx合并插件"Word发现不可读内容"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 docx-merger 库合并docx文件.一切都很好,除了Microsoft Word的"Word在output.docx中发现了不可读的内容.是否要恢复此文档的内容?如果您信任此文档的来源,请单击"是."消息.单击是"时,它将打开文档,但不会打开输出文件,而只是一个缓冲区.

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.

这是我的代码:

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 文件.

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.

推荐答案

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

Header & footer sections is the cause for this issue. Try removing the header and footer sections in the documents.

这篇关于Nodejs docx合并插件"Word发现不可读内容"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆