[reportlab-users] Re: Getting the number of lines in a frame

Saketh Bhamidipati saketh.bhamidipati at gmail.com
Wed Aug 23 12:11:04 EDT 2006


On 8/23/06, Andy Robinson <andy at reportlab.com> wrote:
>
>
> > Now, instead of writing the text and headings separately, I write them
> > together at once in a Table. Though the TableStyle is working well, the
> > Table is not; the right column is not wrapping its text. I tested it out
> > with an addTextAndHeading("text"*100, "heading"), but the
> > texttextexttext[...] runs off the end of the page and doesn't wrap.
> > Since the right column width is 6 inches, I thought it would wrap after
> > going for 6 inches of text.
>
> Plain text does not wrap - this is a performance optimisation for the
> large numbers of tables which display (e.g.) financials.  To get it
> wrapping, put a flowable or a list of flowables in the "table cell" e.g.
>
> Not tested but here's the idea
>   row1 = [   #this has two elements, each a list of flowables.
>     [
>       Para("My heading", style="heading"),
>     ],   #left cell contains one heading para
>
>     [#right cell can hold multiple paragraphs
>      Para("My body first para", style="body"),
>      Para("My body first para", style="body"),
>      Para("My body first para", style="body")
>     ]
>
>
>    ]
>
> tableData = [row1, row2, row3]
>
> table = BlockTable(tableData, style=MyTableStyle)
>
> This sucks a bit in Python but it's way easier in RML as we're all
> trained to parse <table>,<tr>,<td> in our heads these days.  You might
> find it's a good idea to scan the table sample files in the RML suite
> here, and then mentally translate those patterns back into Platypus -
> the objects correspond pretty closely to what you'd expect and will make
> the above seem clearer.  See example 8 here:
>    http://developer.reportlab.com/examples.html
>
>
> - Andy
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
What's a BlockTable? I can't seem to import it:

Traceback (most recent call last):
>   File "C:\Python24\Projects\PDF\hanuman2.py", line 6, in -toplevel-
>     from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer,
> Flowable, BlockTable, TableStyle, Table
> ImportError: cannot import name BlockTable
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://two.pairlist.net/pipermail/reportlab-users/attachments/20060823/d8c4d6d6/attachment.html


More information about the reportlab-users mailing list