Note that there are some explanatory texts on larger screens.

plurals
  1. POStreaming output from Prawn/Prawnto in Rails before render
    text
    copied!<p>Does anyone have any examples of starting the file stream before the rendering/building process when using Prawn?</p> <p>The situation is that I have a report of 350 or so pages that takes about 60 seconds to run on my own workstation, but when moving it to production (EC2) the time to run the report goes up over 300 seconds and when it finishes it does not send the PDF to the browser.</p> <p>Even 60 seconds is a long time without any user feedback but 300 just doesn't work even if you wait. What I have been looking to do is to start the file download before the rendering process (I am using a .pdf.prawn view for this with Prawnto), so that at least the user can see something is happening while it processes, but so far have been unable to do this. All the examples and guides I have found start the download after the render has finished, and after the long wait.</p> <p>If all else fails I will look at scheduling the report but ideally the user would be able to view the report, then go back and make changes and run it again, which scheduling obviously wouldn't allow.</p> <p>Not really much code to show with Prawnto as it's all just PDF layout in the view, and called via this in the controller. I have tried send_file, and moving the PDF layout to the controller to run it without Prawnto, but all changes seem to give the same result - the PDF is sent to the browser after the long wait.</p> <p>I am out of ideas at this point and would appreciate any ideas!</p> <pre><code> respond_to do |format| format.pdf { prawnto :prawn =&gt; {:page_layout =&gt; :portrait, :skip_page_creation =&gt; true}, :inline =&gt; false render :layout =&gt; false } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload