Problem when email PDF generated by jsreport in iPad Chrome



  • Hello everyone,

    I'm facing a tricky problem.

    Situation

    • We are calling jsreport API to generate PDF, i.e. post JSON to API, save the response (PDF) into HTML5 filesystem, and then window.open to open a new window with url = file.toURL() to display the PDF in a pop-up window. This is working perfect for Windows Chrome.
    • Then we find it is somehow not working for iPad Chrome, and this link saved us - we can show the PDF in iPad Chrome with the PDF encoded as data URI. However this PDF cannot be emailed - selecting share > email it puts the lengthy URL into email instead of attaching the PDF file.
    • Now my idea is to open a new window/tab using window.open, then post to jsreport with "options": { "Content-Disposition": "inline" } and specify the new window as the target. However it is very difficult (if not impossible) because:
      • Using ajax I cannot specify a submit target
      • Using normal HTML form submission I cannot submit JSON

    Any thoughts / alternatives / workarounds are appreciated. Thanks!


  • administrators

    hi!, i guess that you are sending the request to jsreport by yourself instead of using the browser-client, right? if for some reason you need to do the request on your own you can take a look at the following code, there you can see how we use form submission to send the request to jsreport, also you will find how we encode a javascript object to make it valid in the form submission



  • Hi @bjrmatos! Thank you so much! Yes we are sending request to server by ourselves. We just missed the browser-client out as the server API is so easy to use and we just use angular $http to post without going through all docs.

    Will give it a try and let you know. Thanks again!



  • Hi @bjrmatos, sorry for late reply.

    Just an update: the browser-client does not resolve my problem. In iPad Chrome it does open a new tab to show the PDF, but cannot email / share it if the PDF is rendered using a POST method. Symptoms:

    • When you select Share icon then choose Email, the URL (which is jsreport server URL) is added to the email body without attachment
    • If you tap on the bottom right corner and choose "Open in..." Chrome says cannot download the PDF.

    I have tried both jsreport.render() and jsreport.download(). All the same.

    iPad Chrome is disappointing.


  • administrators

    hi @ericxinzhang , maybe you can try to workaround the browser limitations by using renderAsync (which does not use a form POST request but uses a AJAX POST request) with window.open in the docs you can find a small example that uses renderAsync, maybe it will help with your case.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.