[reportlab-users] Can a pagetemplate modify its frames?

Roberto Alsina ralsina at netmanagers.com.ar
Thu Aug 28 10:54:58 EDT 2008


I am trying to implement a "smart page" PageTemplate which does things like
adjust margins and show/hide headers and footers depending on the content.

Can I modify self.frames from a PageTemplate?

I tried this to implement a "gutter margin" with no visible effect:

def beforePage(self,canv,doc):
print self.frames[0].__dict__

# Adjust gutter margins
if doc.page%2: #Odd page
gm=self.gm
else: # Even page
gm=-self.gm

print gm

for f in self.frames:
f._x+=gm
f._x1+=gm
f._x2+=gm

The values change but the frame doesn't move :-)

--
("\''/").__..-''"`-. . Roberto Alsina
`9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH)
(_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar
_..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia
(l)-'' ((i).' ((!.' according to alexa.com (27/5/2007)

Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it. --Brian W. Kernighan


More information about the reportlab-users mailing list