Angular 来自字节数组的文档查看器(doc或docx),以4为单位

Angular 来自字节数组的文档查看器(doc或docx),以4为单位,angular,document-view,Angular,Document View,我需要查看最终用户提交的所有附件。我可以查看pdf和图像文件,但无法查看扩展名为doc或docx的文件。 这就是我所做的 let file = null; if (extension === 'pdf') { file = new Blob([new Uint8Array(byteFile)], { type: 'application/pdf' }); } else if (extension === 'jpg' || extension === 'png') { fi

我需要查看最终用户提交的所有附件。我可以查看pdf和图像文件,但无法查看扩展名为doc或docx的文件。 这就是我所做的

let file = null;
  if (extension === 'pdf') {
    file = new Blob([new Uint8Array(byteFile)], { type: 'application/pdf' });
  } else if (extension === 'jpg' || extension === 'png') {
    file = new Blob([new Uint8Array(byteFile)], { type: 'image/png' });
  } else {
    file = new Blob([new Uint8Array(byteFile)], { type: 'application/msword' });
  }
  if (file !== null) {
    const fileURL = URL.createObjectURL(file);
    window.open(fileURL, fileName);
  }

上面的代码适用于chrome和firefox中的pdf和图像文件(不适用于IE)。但是对于doc或docx,它在任何浏览器中都不起作用。有人能告诉我该怎么做吗?

你可以使用像这样的缩略图生成服务。它可以生成许多流行的专有格式的文件预览。披露:我为Post2Preview工作