webodf / ViewerJS

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

How to open an objectURL with ViewerJS? #92

Open KSchreyer opened 10 years ago

KSchreyer commented 10 years ago

pdf.js can be given an objectUrl to a PDF-Blob, like "PATH_TO_PDFJS/viewer.html?file=' + encodeURIComponent(objectURL)".

How can this be done with viewerjs, because "PATH_TO_VIEWERJS/index.html#' + encodeURIComponent(objectURL)" does not work?

Thanks, Kai

adityab commented 10 years ago

This is not yet possible.

A possible solution would require you to modify PluginLoader.js to parse the mimetype from the encoded objectURL, and load the appropriate format's plugin.

Also, both viewer plugins would need to be able to feed this data to the respective backends. Both WebODF and PDFjs can already handle this, just the plugins need to pull the right strings.

QuentinAuthelet commented 10 years ago

Hi, KSchreyer, I'm looking for the same solution. Let me know if you find something. Thanks :)

xenmic commented 9 years ago

A solution that I have just found works is a URL rewrite ...

An example : https://loggedin.mysite.net/js/ViewerJS/#../../showpdf/a3wns3w5e/fred.pdf

I rewrite that to : https://loggedin.mysite.net/download.php?ref=a3wns3w5e

The download file will check that you have permission and stream the file if so ...

The fred.pdf part determines the name in ViewerJS (and it needs to end in ".pdf") - so I set that to the actual file name, but ignore it otherwise.

HTH