[reportlab-users] Getting started

Tim Roberts timr at probo.com
Fri Jan 26 16:04:06 EST 2007


Justin Fagnani-Bell wrote:

> The first is with small fields of text the are supposed to wrap to

> two or three lines, like the street part of an address. Paragraph

> seems to be the only built-in object that does wrapping, but I need

> to make sure that it doesn't expand beyond two lines. I don't

> immediately se a way to do that.

>


It is not hard to do this by hand, and that way you get to control
exactly where the lines break. For example, in pseudo-code:

# Split on white space.
words = line.split()
line = ''
for word in line.split():
if canvas.stringWidth( ' '.join((line,word))) < fieldwidth:
line += ' ' + word
else:
... render line so far ...
... advance y pointer ...
line = word


> The other issue is with the invoice line items. If there are too many

> to fit on a page, then I need to create a second page that's

> different that the first. I assume I'll need platypus for this, but

> will it automatically paginate for me, and how can I tell it how much

> space there is for line items on each page type? Basically the first

> page has a different header and footer than other pages.

>


It's a tough call. I reach for Platypus only when I have something
that's really like desktop publishing -- when I have a document that
truly consists of flowables where the exact positioning doesn't matter
so much. In almost all other cases, I do it by hand. I maintain the Y
pointer myself, comparing it against the bottom value for this part of
the page, and then trigger a page flush when I reach it. It's more
work, but I have more control.


> I'm also interested in hearing if there is an easier approach than

> hand coding the layout in Python. I'd love to be able to design the

> form with an SVG aware vector program and then fill it out and render

> it to PDF with ReportLab. Is there any way to do such a thing?


Not today, but I suspect it's coming.


> If I could even specify the layout in a declarative form, like XML, but

> hopefully a little nicer than XSL:FOP, and fill it out and render

> with ReportLab, that would be better.

>


This would be an excellent spot for Andy to pop in with an advertisement
for ReportLab's commercial products...

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list