[reportlab-users] How to put a newline break in a XPreformatted?

Robin Becker robin at reportlab.com
Thu Feb 28 06:18:51 EST 2008


Shigesan Takuya wrote:

> if you just put in a line break that should work

>

> ie XPreformatted('a\nb\nc',...)

> should be three lines.

>

t = Table([[
[XPreformatted(" This is a very long long long
string to be printed in a PDF Form with a checkbox at the beginning
of \n the first line. Again, a repeated sentence: This is a very long
long long string\n to be printed in a PDF Form together with a
checkbox at the beginning of the first line", someParagraphStyle),
drawCheckBox]]])

Shige, the table you've shown has only one cell that contains a list of things.

I suspect it sould be clearer if we did the data assignments separately

ie

x=XPreformatted(" This is a very long long long
string to be printed in a PDF Form with a checkbox at the beginning
of \n the first line. Again, a repeated sentence: This is a very long
long long string\n to be printed in a PDF Form together with a
checkbox at the beginning of the first line", someParagraphStyle)

then your table looks like

t = Table([[[x,drawCheckBox]]])

ie 1 row, 1 column 1 cell with list contents. The cell will contain the contents
drawn in order.

If you make the table have two columns in the one row then both can have the
same alignment. I'm not sure which side you want the check box, but you could do

t = Table([[x,drawCheckBox]])


or

t= Table([[drawCheckBox,x]])


t.setStyle([('VALIGN',(0,0),(1,-1),'TOP')])
--
Robin Becker


More information about the reportlab-users mailing list