[reportlab-users] Truncate table cell content to end with ellipsis
Yves Forkl
Y.Forkl at srz.de
Tue Apr 14 10:13:03 EDT 2009
Using Platypus (RLTK 2.3), I would like to make sure that the contents
of a table cell of a known fixed width do only consist of no more than a
single line that is truncated if too long. An ellipsis ("...", or rather
U+2026) should be substituted to the missing part. The contents are
passed as a Paragraph so I can use HTML formatting, its font size and
family are known of course.
I already have a kind of hack which involves a function that
incrementally reduces the content to be inserted (using the stringWidth
method on a dummy canvas) until it fits, based on some heuristics.
But I would much prefer a clean and neat solution. I know about
KeepInFrame and its truncate method, but looking at the unit test in
test_platypus_pleaseturnover.py I can't figure out how to proceed,
especially to push the ellipsis in.
Any hints?
Yves
More information about the reportlab-users
mailing list