【问题标题】:Mammoth/Angular ERROR Error: Could not find file in options when converting docxMammoth/Angular ERROR 错误:转换 docx 时无法在选项中找到文件
【发布时间】:2021-10-01 13:33:46
【问题描述】:

这可能是一个愚蠢的问题,但我正在使用 mammoth 在 Angular (10) 中将 docx 文件转换为 html。 我通过输入选择文件,并在按下按钮时将其转换为数组缓冲区,然后将其发送给 mammoth 进行转换。

遗憾的是,我在转换时遇到错误(arraybuffer 似乎没问题)

有谁知道如何解决这个问题?

精度:要将文件转换为数组缓冲区,我使用文件到数组缓冲区模块

转换函数

convertDocument(event):void{
      if (this.fileToUpload!=null){
          fileToArrayBuffer(this.fileToUpload).then((data) => {
          console.log(data);
          
           convertToHtml({ ArrayBuffer : data})
            .then(function(result){
            var html = result.value; // The generated HTML 
            console.log(html);
            var messages = result.messages; // Any messages, such as warnings during conversion 
        })
        .done();
        })
    }
  }

【问题讨论】:

    标签: javascript angular typescript docx mammoth


    【解决方案1】:

    只需将ArrayBuffer : data 替换为arrayBuffer : data

    就是这样……

    【讨论】:

      猜你喜欢
      • 2020-04-18
      • 1970-01-01
      • 2022-06-10
      • 2022-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多