[reportlab-users] Reducing PDF File Size

Robin Becker robin at reportlab.com
Wed Mar 23 14:27:21 EDT 2022


On 23/03/2022 07:13, Lele Gaifax wrote:
> Joseph Dvorak <joseph.dvorak at cambiumassessment.com> writes:
> 
>> I have a document with 4 pages, each having an image page .png background.
>> [...]
>>
>> ReportLab generates a document file of 3.4 MB.
>>
>> How can I *significantly* reduce the size of the PDF file within ReportLab?
> 
> Try converting those PNGs to JPGs: AFAICT, PDF has a specialized reader for
> JPGs, while other formats are stored in base64/base85.
> 
> ciao, lele.

In fact non-jpeg images are now mostly stored with 'Flate' compression

self.streamContent = zlib.compress(raw)

We used to use A85 to try and avoid lots of binary content in the file as old style mailers used to corrupt them.

The image sizes may dominate gilsize because people use high resolution images.
-- 
Robin Becker


More information about the reportlab-users mailing list