1

I got a HTML page with a form. When I post, it returns a pdf based on the form data.

Is it possible to open the browser when submiting (post) the data when the user are in standalone mode? I tried to set target="_blank" in both the form tag and on the submit button but it doesn't work.

It's not any problem if it's an a-tag link. But the problem with a link is that my form doesn't get posted (I know that I can post it trough JS but it will still be in the app).

If it isn't possible to post it with a submit button. I'll need to use a link (or another element) and with Javascript make an event that builds me the URL with a querystring with the form data. And that opens the browser and that will return me the pdf.

(However the main problem is that it isn't no way back to the app when the server give the user a pdf in app-view (standalone). And that problem isn't it any solution for what I can find. That's the reason to why I need to open it in the browser.)

thatsIT
  • 2,085
  • 6
  • 29
  • 43
  • 1
    Have you considered opening the PDF in a Javascript dialog? Like for example https://jqueryui.com/dialog/. If you set the dialog width and height to 98% of full screen you can let the user view the PDF and then close it by pressing the close icon, without leaving standalone mode. – HoffZ Oct 21 '15 at 08:10
  • Actually a good idea! Did never thought of it. However the solution fails because the user still need a pdf viewer installed. And it didn't work on my android tablet. This JS library, https://mozilla.github.io/pdf.js/, seems to work. I havn't tried it out. But quite big library with alot of files to add. Perhaps I'll look it up more later. – thatsIT Oct 21 '15 at 09:49
  • If you have the URL to the PDF you can use the pdf.js viewer. Then, in your dialog, you can have an iframe with this src attribute: http://yourDomain/pdf.js/web/viewer.html?file=myfile.pdf. Documentation: https://github.com/mozilla/pdf.js/wiki/Viewer-options. The pdf.js lib will not be loaded by the client so there is no reason to be concerned about the pdf.js library size. – HoffZ Oct 21 '15 at 14:34
  • Ok! I don't have any location where I store my .pdf. Will it work if the server create a pdf dynamically? – thatsIT Oct 22 '15 at 11:29
  • If the server can create the PDF from an URL, then yes, I think that will work (but I'm not 100% sure). You probably need to send some arguments with the URL so the server knows what to generate. – HoffZ Oct 22 '15 at 11:35

0 Answers0