[reportlab-users] Multiple Columns overflowing into each other?

Robin Becker robin at reportlab.com
Thu Oct 25 06:32:22 EDT 2007

Erik Wickstrom wrote:

either your arithmetic or your assumptions about the frame arguments is/are
wrong. The dimension arguments are x,y,width,height. I tried this hacked version
of your script and it seems to do exactly as required. If you want the sidebar
to be skipped after the sidebar text you'll need to append a NextFrame action
flowable after the sidebar text.

from reportlab.platypus import *
from reportlab.rl_config import defaultPageSize
from reportlab.lib.styles import *
from reportlab.lib.units import *
from reportlab.lib.pagesizes import *
class GazettePageTemplate(PageTemplate):
def __init__(self, id, pageSize=defaultPageSize):
self.pageWidth = pageSize[1]
self.pageHeight = pageSize[0]
print self.pageWidth
print self.pageHeight
frame1 = Frame(0.5*inch,
self.pageHeight - 3.4*inch, id='frame1')
frame2 = Frame(2*inch,
self.pageHeight - 3.4*inch, id='frame2')
PageTemplate.__init__(self, id, [frame1, frame2]) # note lack of onPage

def beforeDrawPage(self, canv, doc):
canv.setFont("Helvetica-Bold", 16.8)
canv.drawString(0, 10, "Footer Text")

def some_view(request):
# Our container for 'Flowable' objects
elements = []

# A large collection of style sheets pre-made for us
styles = getSampleStyleSheet()

# A basic document for us to write to 'hello_platypus.pdf'
doc = SimpleDocTemplate('hello_platypus.pdf')
doc.pageTemplates[:] = [GazettePageTemplate('First')]

from reportlab.rl_config import defaultPageSize

(MAXWIDTH, MAXHEIGHT) = defaultPageSize

#image = Image('/root/journal/gazette/paper1.png')
elements.append(Paragraph('Sidebar head', styles['Heading1']))
elements.append(Paragraph('This is a sidebar text', styles['Normal']))
elements.append(Paragraph("""Vulputate velit esse molestie
consequat vel, illum dolore eu feugiat nulla! Legere me lius quod ii
legunt saepius claritas est etiam processus dynamicus qui. Ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat duis autem
vel eum. Eleifend option congue nihil imperdiet doming id quod? Typi
qui nunc nobis videntur parum, clari fiant sollemnes in.
Demonstraverunt lectores sequitur mutationem consuetudium lectorum
mirum est notare. Dolore te feugait nulla facilisi nam liber tempor
cum soluta nobis? Dignissim qui blandit praesent luptatum, zzril
delenit augue? Ad minim veniam quis nostrud exerci tation iriure dolor
in, hendrerit in facilisis at vero eros. Odio duis mazim placerat
facer possim assum typi non habent claritatem insitam est usus
""", styles['Normal']))

# Write the document to disk

Robin Becker

More information about the reportlab-users mailing list