Marcelh1983 / document-viewer

MIT License
50 stars 25 forks source link

Why ngx-doc-viewer is not displaying pdf file(file is on local disk) in angular10? #19

Closed fahadsubzwari924 closed 3 years ago

fahadsubzwari924 commented 3 years ago

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

component.html

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

my url is forming like this http://localhost:PORT/documents/bids/bidId704/proposalDoc_Monday_June_28th_2021_8_49_01_PM.pdf

When i load just this url so that it loads PDF file in chrome perfectly but when i try with ngx-doc-viewer so it is giving an error one chrome's console

  `Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist`.

How can i fix it?

Marcelh1983 commented 3 years ago

Hi @fahadsubzwari924, the google viewer needs the file to be publicly available. So it probably will work when you deploy your application but the google viewer cannot access your localhost

fahadsubzwari924 commented 3 years ago

So it will not work if i will change viewer="url" ?

fahadsubzwari924 commented 3 years ago

Hi @fahadsubzwari924, the google viewer needs the file to be publicly available. So it probably will work when you deploy your application but the google viewer cannot access your localhost

Now i am using mammoth for locally uploaded file preview but now it is previewing only .docx file. Other than .docx it is giving an error on console. see this https://stackoverflow.com/questions/68166751/why-ngx-doc-viewer-is-not-displaying-pdf-filefile-is-on-local-disk-in-angular1/68167462#68167462

wns-madhuri commented 6 months ago

<ngx-doc-viewer [url]="inputFile.filePath" viewer="url">

How can i check content load or not. I m getting refuse to connect iframe.