pypfdf - how to make text wrap table cells?

86 views
Skip to first unread message

at

unread,
Sep 3, 2015, 6:43:40 AM9/3/15
to web2py-users
Hi,

I was trying to use the first sample report from: https://code.google.com/p/pyfpdf/wiki/Web2Py. I modified it a little to fill the data dynamically inside the table, but the long text is not wrapping inside the table cells. I've tried setting different css to address the issue but no luck.

Any idea how to fix it?

Thanks a lot. 

Edwood

unread,
Sep 6, 2015, 12:55:25 AM9/6/15
to web...@googlegroups.com
Hi.

Wrapping inside table columns is not currently supported by "write_html", nor are CSS properties. 

One way to render wrapped text inside tables is to build the table using lines and then use "multi_cell" to wrap text inside the columns.  This technique will require you to maintain careful track of the current position inside de PDF document.  Some examples that may help you (disclaimer: written by me):
 You may also try Weasyprint (http://weasyprint.org/) which supports CSS styles.  I have no experience with it yet, but looks interesting.

at

unread,
Sep 6, 2015, 2:55:29 AM9/6/15
to web2py-users

Thanks a lot Edwood for your help. I'll definitely try to follow your tips.

Best Regards,
AT

On Sunday, 6 September 2015 09:55:25 UTC+5, Edwood wrote:
Hi.

Wrapping inside table columns is not currently supported by "write_html", nor are CSS properties. 

One way to render wrapped text inside tables is to build the table using lines and then use "multi_cell" to wrap text inside the columns.  This technique will require you to maintain careful track of the current position inside de PDF document.  Some examples that may help you (disclaimer: wrote by me):
Reply all
Reply to author
Forward
0 new messages