3

In my angular10 in which i have to display a PDF file as a preview. So for that i am using ngx-doc-viewer. My component is look like this

component.html

<ngx-doc-viewer [url]="inputFile.filePath" viewer="mammoth" 
  style="width:100%;height:60vh">
</ngx-doc-viewer>

component.ts

const reader = new FileReader();
reader.readAsDataURL(inputFile);
reader.onload = (_event) => {
  this.inputFile.filePath = reader.result;
}

angular.json

scripts : [
 "node_modules/mammoth/mammoth.browser.min.js"
]

When i upload any .doc,.docx,.xlsx file so that it loads that file in chrome perfectly but when i try with ngx-doc-viewer so it is giving an error in chrome's console

Unsupported viewer: 'mammoth'. Supported viewers: google, office.

enter image description here

How can i fix it?

Fahad Subzwari
  • 2,109
  • 3
  • 24
  • 52
  • if you want to show only pdf then you can check the link 'https://stackoverflow.com/questions/69984988/unable-to-show-blob-url-in-pdf-viewer-ng2-pdf-viewer-in-angular-10', however if you want to show docx and other format then ngx-doc-viewer is the only option but it does not work as you wanted. – Srijon Chakraborty Nov 16 '21 at 11:04

0 Answers0