[reportlab-users] Scaling and Translation

Ian Sparks Ian.Sparks at etrials.com
Tue Jul 5 16:26:52 EDT 2005



I have a set drawing operations that render a complex shape. Ordinarily the shape wouldn't fit on the canvas page so I'm going to scale the shape.

So :

from reportlab.lib.units import inch
from reportlab.pdfgen import canvas

canv = canvas.Canvas("D:/PDFGen2/t.pdf")
canv.scale(0.5,0.5)       #Make all drawing operations half-size
canv.rect(0,9 * inch,inch,inch) #Draw an inch-square box 9-inches up the page.
canv.save()

BUT! I want to maintain the position of the box at 9 inches from the bottom of the page even though I want it to draw half-size. The above code will draw it 4.5 inches from the top of the page.

I can adjust to this :

canv.rect(0,9 * inch * 2,inch,inch) #Draw an inch-square box (account for scaling)

but that means touching every drawing operation. 

So My question : Is there a better, more global way to achieve this?





More information about the reportlab-users mailing list