mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.62k stars 10k forks source link

Browsers other than Firefox #8587

Closed SPlatten closed 7 years ago

SPlatten commented 7 years ago

I've downloaded pdf.js tonight with a view to using it for a project. I tried the viewer.html with Safari and whist the viewer loads, the PDF did not. I then tried it with Firefox and it all works perfectly.

It doesn't work in chrome either. Is there any intent to get this working with all the major web-browsers ?

When trying this:

https://mozilla.github.io/pdf.js/web/viewer.html

With Safari online it works fine, but the offline demo:

file://svr/pdfjs/web/viewer.html

Does not ?

mukulmishra18 commented 7 years ago

When trying this: https://mozilla.github.io/pdf.js/web/viewer.html With Safari online it works fine, but the offline demo:

What about chrome?

file://svr/pdfjs/web/viewer.html Does not ?

Maybe but not sure, this seems to be a problem of file:// protocol, some browsers does not allow to access local files using xhr due to security reasons. Basically it violates Access-Control-Allow-Origin.

SPlatten commented 7 years ago

Thank you, that makes sense.

Snuffleupagus commented 7 years ago

As mentioned in the README, see https://github.com/mozilla/pdf.js#getting-the-code, not all browsers support file:// URLs. The solution is to use a web server; closing as answered.