[reportlab-users] PDF Generation performance

Chuck Bass reportlab-users@reportlab.com
Wed, 24 Dec 2003 09:23:56 -0800 (PST)

I am having a similar issue with a much smaller document.  I have used reportlabs code
create test reports that span a handfull of pages with tabular results and graphical 
representation of the results using PIL generated images. Very little if anything 
spans pages.  These reports take a second or two to generate.

Yesterday I threw together a calendar program to make some xmas gifts.  I found that a
12 page document each with 1/2 image and 1/2 5week table takes 30 seconds to render.  
The images are all JPEGs and about 500K but there is nothing fancy going on.  
Each page is a template so there are no breaks.  All of the code before the .build call
takes less than a second to execute.

I have noticed that the generated printer file is about 100meg!  My machine is a 2.4GHz with 
512 megs of RAM so it's not a slouch.  Is it possible that there is some copying going on
that makes life tough as the document size goes up?  Perhaps it forces the machine to start

Great work on reportlabs, I hope to never make an HTML based report again!


>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)
>reportlab-users mailing list

reportlab-users mailing list

Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.