webodf / ViewerJS

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

Does ViewerJS works with blob, stream or base64? #216

Closed AlexandreLPentila closed 8 years ago

AlexandreLPentila commented 8 years ago

Hi,

I'm trying to use your Viewer to display some PDF for all platform (Computer & mobile), which works great when I try to directly display a file.

But when I try with my global stack (UI with JS on liferay back end) I got some trouble. In fact, my liferay is based on tomcat and I use struts action to get file. A call to struts action looks like :

When I directly try to call ViewerJS with the following call :

I also tried base 64 like describe in #6 with a request like : https://My_URL/ViewerJS/#data:application/pdf;base64,JVBERi0xLjY................. I try it on chrome and firefox

Is it a mistake from myself? Is it a known issue? Do you have some work around?

Thanks a lot for any help!

Regards

vandenoever commented 8 years ago

Please check in the network tab of 'Inspect Element' to see there is a call to the pdf file.

AlexandreLPentila commented 8 years ago

@vandenoever thanks for answer

For the base 64 try : Firstly I do a Jquery.GET on my URL which return the file content I convert in base64. Then, I just have to write the Base 64 at the end of the URL (which can be huge).

In network : I can see my GET on URL and file content in response.

For the "Jquery file" try : When I Call the URL : https://My_URL/ViewerJS#../c/document_library/get_file?p_l_id=4179750&fileEntryId=4335401

I see in network the following call : https://My_URL/c/document_library/get_file?p_l_id=4179750&fileEntryId=4335401 with HEAD request method which have nothing in response. But there is no GET call.

For the "Direct file" try : I got a HEAD request without response and a GET resquest with file in response. And it's works.

If you need more elements, ask them ;). Once again thanks for support.

vandenoever commented 8 years ago

Using the direct file method is simplest and most efficient. You say the direct file try works. Is there a reason that you cannot use that? If that does not work with the get_file URI, then you may have to escape the '&' and '=' symbols. What network traffic do you see when you try https://My_URL/ViewerJS#../c/document_library/get_file?p_l_id=4179750&fileEntryId=4335401 ?

AlexandreLPentila commented 8 years ago

I know it's the simplest I can't in production. I just use It to test ViewerJS. I need to call the method getFiles which verify user permission some stuff like that. My direct access is on the same serve but just try to access to a file I manually add to my /var/www directory

You can see the network calls There is redirection from "Viewer#../myCall" to "ViewerJS/#../myCall" but this redirection also exists when i try to access directly ("Viewer#../myFilePath").

If you need more details for some request I can post more details

AlexandreLPentila commented 8 years ago

Hi ,

Didn't solve the issue but I tried PDF.js and it work as expected, then I will use it.

Thanks for help.

memorx commented 7 years ago

Hi, can you share how do you solve your issue using PDF.js? thank you

zenzei commented 7 years ago

Hi @AlexandreLPentila, can you share how you resolved this issue? I'm having the same problem when streaming a file instead of static file. Thanks,

navinagarwal11 commented 4 years ago

Hi @AlexandreLPentila Please share how you have fixed the issue I am also facing same issue in Liferay 7.2

jdiazgon55 commented 3 years ago

This works for me

<iframe src="ViewerJS/#data:application/pdf;base64,JVBER....." >