Re: Table rendering speed tips

89 views
Skip to first unread message

Kashyap KMBC

unread,
Jul 4, 2012, 2:32:59 AM7/4/12
to prawn...@googlegroups.com
Regarding the (2)nd issue, you can do all the processing in a background job so that the user is not made to wait until the file gets rendered. Resque is a library that can be used to this effect, Sidekiq is another one.

-- 
Kashyap KMBC

On Wednesday 4 July 2012 at 5:07 AM, Michael Graff wrote:

Howdy.  I am rendering a class schedule, using one table per day.  I'm running into problems:

(1)  Using rowspan with row-coloring is odd.  The rowspan-using column has stripes too.  :)  This can be avoided by explicitly coloring each cell and tacking even/oddness.

(2)  Rendering my 156-page document takes 45 seconds.  This is not fast enough for interactive browser-download-on-the-fly work.

(3)  Specifying table width works.  Specifying column widths as well fails:

          pdf.table(items, header: true, width: 720, column_widths: [ 10, 20, 10, 10 ],
            cell_style: { overflow: :shrink_to_fit, min_font_size: 10 })

Table's width was set larger than its contents' maximum width (max width 50, requested 720)

  Specifying column widths alone also fails.

Any idea on how to fix (2) and (3) at least?

I am basically rendering one header, then groups of { one row with 4 columns, one row with colspan=4 } for each data element.


Christopher Jaeger

unread,
Jul 4, 2012, 4:54:42 AM7/4/12
to prawn...@googlegroups.com

Delayed job as well, though I recommend resque. Don't forget page caching if your PDF is semi static!

Michael Graff

unread,
Jul 4, 2012, 12:32:37 PM7/4/12
to prawn...@googlegroups.com
Thanks for the reqsue suggestions.  I actually already use it for other things, and love it overall.

I already thought of generating it in the background and sending it along via email, or allowing it to be downloaded later once generated.  And caching is a requirement of course, which for the "everything' file means one person only will need to take the speed hit -- and I could generate that as part of my deployment process.

--Michael
Reply all
Reply to author
Forward
0 new messages