[reportlab-users] Extra Canvas Translation?

Robin Becker robin at reportlab.com
Sun Sep 18 07:22:29 EDT 2005


Carl wrote:
> I have been experimenting with the interaction between the flowable elements 
> of the Platypus engine and the non-flowing drawing routines of pdfgen.  In 
> one of my examples, I am rotating a page so it will print out landscape-wise.  
> I place a non-flowing banner on it with the PageTemplate event hooks, and I 
> place some paragraph text on the page with the Platypus engine.
> 
> However, I also attempted to place some non-flowing content on the page by use 
> of a variation on the Macro flowable.  I was puzzled when it did not show up 
> as expected, but then I decided to print out the absolute coordinates of the 
> canvas origin in each case.  To my surprise, the origin has been translated 
> off the page!  Can anyone help me understand why this is happening?  My 
> example program follows:
....

the flowable.drawOn action is called by the frame with the current frame 
position as arguments. In order to allow 'normal' floables to use self 
relative coordinates the 'standard' drawOn method translates the origin 
to the current position in the frame which calls the drawOn method when 
adding flowables. It should be relatively easy to create a new drawOn 
method which doesn't do the translation and use that in your macro. 
Alternatively you can start your draw method with 
self.canv.restoreState() to remove the translation and finish it with a 
fake self.canv.saveState() to provide drawOn with something to restore.
-- 
Robin Becker



More information about the reportlab-users mailing list