[reportlab-users] Creating Large PDF Files

Andy Robinson reportlab-users@reportlab.com
Thu, 6 Mar 2003 07:11:51 -0000


(Sorry, hit the wrong key a moment ago and sent a blank reply).

Currently we do always process in memory.  PDF files are full of cross
references and it is impossible to write the file without knowing
everything about it; it's not like HTML or text where you can write the
beginning, the middle and then the end :-(.  So, we decided early
on to create the whole thing in memory.  Another approach would have
been to write each page to disk in a special format and assemble them
at the end, but we have not implemented that.  We also decided
that it should be possible to render, say, a 1000-page book
on a well-specced PC, and that was good enough.

The first thing to ask is, are you making efficient use of forms
for any content which is common across many pages?
I've seen repetitive apps (ten thousand customer statements)
which could be done in 5Mb one way or 500Mb another way.

The next thing is, is it cheaper to buy a small fistful of
memory chips than to write code to

The third is, if your app is that big, would it not be easier
for everyone to split it into 'chapters'?  It's generally bad to
hit print on a document more than 500 pages long as you are almost
certain to have to change per trays in mid-printing?

These are all 'excuses' and not solutions but worth asking your
manager about.  If it's really critical, get back to me and I may
be able to outline a solution, but it will need some work...

- Andy




-----Original Message-----
From: reportlab-users-admin@reportlab.com
[mailto:reportlab-users-admin@reportlab.com]On Behalf Of Engel, Gregory
Sent: 05 March 2003 17:13
To: reportlab-users@reportlab.com
Subject: [reportlab-users] Creating Large PDF Files


By large, I mean 500+ MB.  (Managers ask for the funniest things.)  Is there
a way to save an incomplete PDF file to disk, and thus clear the memory,
while processing large amounts of raw data?  I've hit a memory barrier where
ReportLab quits processing the data and Python throws and
"exceptions.MemoryError".  It seems that ReportLab attempts to keep the
incomplete PDF in memory until the pdfgen.save method is called.
Thank you,
Gregory Engel
Senior Software Engineer
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
My other computer is spongy gray matter.