[reportlab-users] reducing size of SVG rendered image

Robin Becker robin at reportlab.com
Wed May 25 05:03:21 EDT 2011

On 24/05/2011 21:46, Elan Noy wrote:

> Hello,


> I have created an image using svglib and want to have it in a platyfus generated

> PDF.

> I get the image but it is too big. I used Drawing.resized() and it became

> smaller but still too big foir the page.


> I tried to reduce its size by placing it in a table but the image was not reduced.

> I tried to use Drawing.scale(() and got an odd error AttributeError: 'NoneType'

> object has no attribute 'getKeepWithNext'


> So I really don't know what to do. There has to be a way to shrink the image,

> please let me know if you know one,


> Thanks in advance


> Elan Noy


Drawings are flowables so platypus knows how to use them. Drawings have a width
and height for the final size, but that won't affect the contents ie it will
draw outside. Nothing you do outside the Drawing will affect its size it is what
it is.

I believe you need to do the following.

1) Fix the size of the drawing at some width and height that will fit on the page.

2a) Use the transformation matrix of the drawing to adjust the size of its
contents eg

d.transform = (0.5,0,0,0.5,0,0)


2b) set the drawings renderScale to scale the image sensibly eg

d.renderScale = 0.5

Robin Becker

More information about the reportlab-users mailing list