[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,
					   inch,
					   1*inch,
					   self.pageHeight - 3.4*inch, id='frame1')
		frame2 = Frame(2*inch,
					   inch,
					   7*inch,
					   self.pageHeight - 3.4*inch, id='frame2')
		PageTemplate.__init__(self, id, [frame1, frame2])  # note lack of onPage
	def beforeDrawPage(self, canv, doc):
		#self.canv.drawImage('/root/journal/gazette/paper1.png',0,0,8.5*inch,11*inch)
		#canv.drawImage('/root/journal/gazette/paper1.png',0,0,11*inch,8.5*inch)
		canv.setFillColorCMYK(0,0.5,0.87,0.14)
		canv.setFont("Helvetica-Bold", 16.8)
		#p.hAlign('CENTER')
		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')]
	doc.pagesize=landscape(letter)
	from reportlab.rl_config import defaultPageSize
	(MAXWIDTH, MAXHEIGHT) = defaultPageSize
	#image = Image('/root/journal/gazette/paper1.png')
	print MAXWIDTH
	print MAXHEIGHT
	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
legentis.
	""", styles['Normal']))
	# Write the document to disk
	doc.build(elements)
some_view(None)
-- 
Robin Becker
    
    
More information about the reportlab-users
mailing list