[reportlab-users] Long strings without spaces exceed the page margins

Tim Roberts timr at probo.com
Tue Jul 13 13:06:18 EDT 2010


Fabrizio Tronci wrote:

>

> I've noticed that if in the text I use a long string without spaces

> (like a long file path or sequences of html tags without spaces), the

> string exceed the page margins (making text unreadable).

> How can I break the string in two pieces, like using a hyphenation in

> a text editor?


You do it by hand. Hyphenation is a complicated topic, and the
mechanisms depend greatly on the context. There is, for example, no
general rule on how to break a pathname. Only you know what would be
acceptable to you.

Please remember that ReportLab was designed as a way to produce PDFs.
It was originally a relatively thin wrapper over the PDF spec. It was
not designed as a programmable desktop publishing engine. With
Platypus, it can do some of the things that you need for desktop
publishing, but with limits.



> using the Table flowable, you can only set the width of any individual

> columns. How can I set a fixed width for the table, automating the

> calculation of the individual columns width with the lenght of the

> strings in the cells?


Again, that's a rather complicated high-end desktop publishing task,
especially when the text in the cells can wrap. You're expected to know
your data well enough to set the column widths yourself.

Now, if you dig in to this and come up with a good extension to
ReportLab for generating optimal column widths from a given data set,
I'm sure the ReportLab folks would be tickled pink to include it in the
package. However, you'll quickly find out how hard of a problem that
is. HTML has had the <table> tags since the very first version some 20
years ago, and to this day the browsers can't all agree on the layout in
every case.

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



More information about the reportlab-users mailing list