[reportlab-users] frames vs. tables

Chris K. reportlab-users@reportlab.com
Fri, 28 Nov 2003 17:27:39 +0100


Hi,

I’m writing an external Zope method based on the rlzope.py example.
In contrast to the example I want to create three independent columns that I 
fill with flowables. Independent means that I need to be able to add a paragraph 
to a random column.

My first approach was to use frames:

class MyPDFDoc :
   class MyPageTemplate1(PageTemplate) :
     """My 1st page template."""
     def __init__(self) :
       row1 = Frame( 0.3 * cm, 0.7 * cm,  9.3 * cm, 20  * cm, showBoundary=1)
       PageTemplate.__init__(self, "MyTemplate", [row2])

   class MyPageTemplate2(PageTemplate) :
     """My 1st page template."""
     def __init__(self) :
       row2 = Frame( 10 * cm, 0.7 * cm,  9.3 * cm, 20  * cm, showBoundary=1)
       PageTemplate.__init__(self, "MyTemplate", [row2])

   def __init__(self, context, filename, text) :
     # save some datas
     self.context = context
     self.built = 0
     self.objects = []

     # we will build an in-memory document
      self.report = cStringIO.StringIO()

     # initialise a PDF document using ReportLab's platypus
     self.document = BaseDocTemplate(self.report)

     # add our page template
     self.document.addPageTemplates((self.MyPageTemplate2(self), 
self.MyPageTemplate1(self)))

[… Add some flowables to the frames]

However, only MyPageTemplate2 gets drawn. As far as I understand 
reportlab/platypus/ doctemplate.py, 'addPageTemplates' should be able to handle 
lists of frames. What’s the trick?

Other question:
For the above layout: are tables the better approach?

Regards
Chris