[reportlab-users] Re: Getting the number of lines in a frame
Andy Robinson
andy at reportlab.com
Wed Aug 23 12:02:07 EDT 2006
> 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
More information about the reportlab-users
mailing list