[reportlab-users] PDF Report size too large

Roberto Alsina ralsina at netmanagers.com.ar
Mon Jan 23 15:38:57 EST 2012


On 1/23/2012 5:30 PM, Jean-Yves F. Barbier wrote:

> On Sat, 21 Jan 2012 05:15:14 +0000

> Asif Jamadar<asif.jamadar at rezayat.net> wrote:

>

>> I'm using Reportlab tool to generate dynamic PDF.

>> The generated PDF consist of 1 or 2 pages but the size this PDF

>> reached to 5 MB. How can I decrease the size of the generate PDF.

>>

>> I want to decrease the size to max 500 TB. IS there any way to

>> accomplish this thing in reportlab?

> This is finally a good question, indeed - so I made some tests.

>

> Greping RL code shows that it use zlib; if it's a good&

> fast compression technique for communications it is not

> as good for file compression.

>

> I didn't wanted to modify RL code, so I found this way:

> * create an uncompressed PDF w/RL

> * transform it to PostScript

> * re-transform PS to PDF

>

> It lowered an already RL compressed PDF from 258kB to 74kB

> (3.5x less) - but the chances to lower to 500kB from 5 MB

> are very low...


The main reasons for a PDF to reach 5MB are:

1) It's really really long. If that's the case, you can enable compression.
2) It has embedded fonts. If that's the case: don't.
3) It has images. You can make this smaller by using worse quality
images, or by removing them.

Without a sample PDF, it's not possible to know what's the cause, though.


More information about the reportlab-users mailing list