views:

389

answers:

1

I'm using the Table of Report Lab library to print a table on a PDF report. I would like to know if it's possible to configure the table to perform an automatic wrapping of the content of a cell.

For example, I have a text that doesn't fit on a cell inside a column. I would like that the table performs the wrap automatically adjusting the content of the cells to fit on the columns width. Is it possible?

+1  A: 

You can put any flowable in a table element. It is probably good practice to have all table elements as flowables, so they can be styled the same. For your case you will most likely need a Paragraph flowable. eg.

styles = getSampleStyleSheet()
text = Paragraph("long line",
              styles['Normal'])

You can put `text' into the data you feed to a table and it will automatically wrap.

David Raznick
I will not test this right now, but reading the user guide again I think that your suggestion is right and will work, so I will mark this as the accepted answer. Thanks. :)
Pedro Ghilardi
I test it now and it really works, wrapping by word. Thanks man!
Pedro Ghilardi