[reportlab-users] Landscape PDF Problems

Albert Leibbrandt albertl at compuscan.co.ug
Fri Sep 17 08:05:31 EDT 2010


I am having a bit of a strange problem at the moment and I am hoping
someone out there can spot my mistake.
I have created 2 document templates, one for docs that should be aligned
portrait and one for landscape docs (extract of code is below).

If I use the SimpleDocTemplate, altering the page size attribute,
landscape docs are created perfectly, but the same is not true when I
use BaseDocTemplate combined with the custom templates listed below.
What is happening is that my text is aligned in landscape but the page
remains portrait, so my document is being cut off on the right (about
2/3) and the text only start about a third of the way down the page

Does anybody have any ideas / advice ?
Oh and I am using reportlab 2.3 with python 2.5.4.

class CS_Portrait_Template(BaseDocTemplate):

def __init__(self, filename, pass_strength, name, **kw):
self.allowSplitting = 0
self.pagesize = A4
self.topMargin = 30*mm
self.title = name
self.author = 'blah'
self.pageCompression = 1
self.showBoundary = 0

apply(BaseDocTemplate.__init__, (self, filename), kw)

framem = Frame(self.leftMargin, self.bottomMargin, self.width,
self.height, id='normal')
self.addPageTemplates([PageTemplate(id="FirstPage",
onPage=myFirstPage, frames=framem),
PageTemplate(id="LaterPages",
onPage=myLaterPages, frames=framem)])

class CS_LandScape_Template(BaseDocTemplate):

def __init__(self, filename, pass_strength, name, **kw):
self.allowSplitting = 0
self.topMargin = 30*mm
self.pagesize = landscape(A4)
self.title = name
self.author = 'blah'
self.pageCompression = 1
self.showBoundary = 0

apply(BaseDocTemplate.__init__, (self, filename), kw)

framem = Frame(self.leftMargin, self.bottomMargin, self.width,
self.height, id='normal')
self.addPageTemplates([PageTemplate(id="FirstPage",
onPage=myFirstPage_landscape, frames=framem),
PageTemplate(id="LaterPages",
onPage=myLaterPages_landscape, frames=framem)])



much appreciated
albert



More information about the reportlab-users mailing list