views:

133

answers:

1

I'm wondering if there is some functionality to split table row on 2 and more pages. Cause some information in row can be too long for one page. And if one row longer then page size then it's cause an exception.

A: 

ReportLab does not text wrapping out of the box, so I am assuming you are either using a para in the table cells, or you are breaking your lines manually with simpleSplit.

If you text is one line string then you can use

from reportlab.pdfbase.pdfmetrics import stringWidth
textWidth = stringWidth(text, fontName, fontSize)

If your text was multi-lines, assuming you are working in a rectangular area with defined width, then do

from reportlab.lib.utils import simpleSplit
lines = simpleSplit(text, fontName, fontSize, maxWidth)

lines is a list of all the lines of your paragraph, if you know the line spacing value then the height of the paragraph can be calculated as lineSpacing*len(lines)

If this proved to be longer than your page then using whatever template you are in (preppy, django, ninja, etc) finds a good breaking point for your text and ends the current row and starts a new one.

I hope this helps

Meitham

p.s. you could always send your questions to the reportlab mailing list and they usually very quick in answering these questions.

Meitham
For now, i just splitting my text by the "new line" and then working with list of lines, each line get one row in table.But i think that ReportLab RML package must have such functionality to split text automatically.if i have free time, i will try to write some patch for this bug.
Creotiv