Search code examples
javascriptangulartypescriptdocxmammoth

Mammoth/Angular ERROR Error: Could not find file in options when converting docx


It's probably a stupid question but i'm using mammoth to convert docx files to html in Angular (10). I'm choosing the file through an input and converting it to an array buffer when a button is pressed then I send it to mammoth to be converted.

Sadly I get an error at the conversion (the arraybuffer seems ok)

Does anyone know how to fix this ?

Precisions : to convert the file to an arraybuffer i use the file-to-array-buffer module

Convertion function

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

Solution

  • just replace ArrayBuffer : data by arrayBuffer : data

    that's it...