webodf / ViewerJS

ViewerJS: Document Reader in JavaScript
http://viewerjs.org
1.94k stars 421 forks source link

Add example/FAQ to viewerjs.org that deals with CORS problems #105

Open kossebau opened 9 years ago

kossebau commented 9 years ago

How to display PDFs from external servers seems to be a not uncommon problem. So this should be documented on viewerjs.org in some way.

vhugogarcia commented 9 years ago

I agree, some documentation to load external PDF files will be awesome. I need to do that, but no documentation or information about it.

Any suggestions or hint or sample for iframe to open it from external?

becassin commented 9 years ago

same here

caiowilson commented 9 years ago

cross-domain loading is not really viewerjs issue. google about CORS and cross-domain configurations. it depends (mostly) on the server the document is in.

kossebau commented 9 years ago

To display files from another server Instead of a relative path to the local file one puts the complete url behind the # char, e.g. 'http://mytestviewerjsdomain/ViewerJS/index.html#http://domain/some/path/to/document.pdf'

See for related discussion comments on #91 and lookout for the current need to have url end with .pdf and CORS problems

quytang commented 6 years ago

I encounter the same problem! How to work around? Seem this repo is not active?

khaidev commented 6 years ago

Idea to work around.

  1. Create a service on your site - This service download ext file and return file content. /get-file?ext=path-external-file Ex: /get-file?ext=http://domain/some/path/to/document.pdf
  2. To display file http://yourdomain/ViewerJS/index.html#/get-file?ext=http://domain/some/path/to/document.pdf
quytang commented 6 years ago

That proxy is not so good. I just found the way to do that for s3. Add allow header origin for the bucket. It works fine.