[reportlab-users] PDF Generation performance

John Precedo reportlab-users@reportlab.com
Wed, 24 Dec 2003 11:56:10 -0000

Hi Shayan

I tend not to work with the open source stuff, but I can point you at the
sort of things that are mentioned when large reports with tables are

The first thing is - are you doing everything in a single table? It is both
better and faster to do multiple small tables rather than one huge one, or
even a few big ones. With tables which spread over multiple pages you get a
lot of time being wasted in repagination and calculating how the cells need
to be resized or flipped onto the next page. You can avoid all this pain by
having multiple smaller tables which don't need to do all this calculation.
(Another minor point is that tables don't have to be nested - it can be
visually equivalent to have totally separate tables which but up against
each other with no space separating them - unless a page break is involved).

The other thing is using forms. You say a lot of the info is duplicated -
using forms can drastically improve timings.

This is describe in section 4.1 of the ReportLab User Guide:

 "The Form feature lets you create a block of graphics and text once
  near the start of a PDF file, and then simply refer to it on
  subsequent pages. If you are dealing with a run of 5000 repetitive
  business forms - for example, one-page invoices or payslips - you only
  need to store the backdrop once and simply draw the changing text on
  each page. Used correctly, forms can dramatically cut file size and
  production time, and apparently even speed things up on the printer."

Hope these hints are of some use to you - if not, perhaps Robin or Andy or
one of our other developers would be able to assist more.

Regards (and a Merry Xmas),

John Precedo               (johnp@reportlab.com)
Reportlab Europe Ltd  (http://www.reportlab.com)