[reportlab-users] Re: Getting the number of lines in a frame
Henning von Bargen
H.vonBargen at t-p.com
Thu Aug 24 03:17:04 EDT 2006
This is expected and documented behaviour.
If you want your text line-breaked,
just use a platypus.Paragraph object instead of a string object
for your cell data. This will break your text as expected.
However, if a single word is longer than the column width,
it will still run off the table.
This is due to the limited word-breaking of the Paragraph class.
You might use my hyphenation library that contains a replacement
for some RL 1.19 platypus classes - this will break your text
at "-" or hyphen characters as well and if a single word is too long,
it will try to squeeze it a little bit or otherwise just break
in the middle of a word. See http://deco-cow.sourceforge.net and
scan this mailing list for my old postings regarding this topic.
The home page contains two sample PDFs as well.
For languages other than German you should use the BaseHyphenator
class instead of the SiSiSiHyphenator that is used in the samples.
HTH
Henning
> On 8/22/06, Saketh Bhamidipati <saketh.bhamidipati at gmail.com> wrote:
> >
> > On 8/22/06, Andy Robinson <andy at reportlab.com> wrote:
> > >
> > > Saketh Bhamidipati wrote:
> > > >
> > > > I need to create documents with headings on the left
> side and text on
> > > > the right side, the headings aligned with the text.
> > >
> > > Each time you need to create a new heading, make a
> two-cell table with
> > > one row. Put a heading paragraph in the left cell, and as many
> > > paragraphs as you want in the right cell. Then add this
> to the story.
> > >
> > > This will also encourage the page breaks to happen in
> nice places, since
> > >
> > > a single table cell is never split.
> > >
> > > Look at reportlab/test/test_platypus_tables.py and its output for
> > > examples of code to build tables.
> > >
> > > Hope this helps,
> > >
> > >
> > > Andy Robinson
> > > CEO/Chief Architect
> > >
> > > _______________________________________________
> > > reportlab-users mailing list
> > > reportlab-users at reportlab.com
> > > http://two.pairlist.net/mailman/listinfo/reportlab-users
> > >
> > That sounds a lot better than what I was doing. I'll try
> the table method,
> > then.
> >
> > Thanks for your help.
> >
> > -Saketh
> >
> I'm having some trouble getting the right column to wrap
> properly. I want a
> table of 2-inch width on the left, and 6-inch width on the
> right. Here is my
> code:
>
> ...
> self.style = TableStyle([
> ('TOPPADDING', (0, 0), (-1, -1), 0),
> ('BOTTOMPADDING', (0, 0), (-1, -1), 0),
> ('LEADING', (0, 0), (-1, -1), 10),
> ('FONTSIZE', (0, 0), (-1, -1), 10),
> ('ALIGN', (0, 0), (-1, -1), 'LEFT')])
>
> def addTextAndHeading(self, text, heading):
> # Called thrice for testing the LEADING and PADDING
> style options
> data = (heading, text), (heading, text), (heading, text)
>
> self.story.append(Table(data, colWidths=(2 * inch, 6 * inch),
> style=self.style))
>
> Now, instead of writing the text and headings separately, I write them
> together at once in a Table. Though the TableStyle is working
> well, the
> Table is not; the right column is not wrapping its text. I
> tested it out
> with an addTextAndHeading("text"*100, "heading"), but the
> texttextexttext[...] runs off the end of the page and doesn't
> wrap. Since
> the right column width is 6 inches, I thought it would wrap
> after going for
> 6 inches of text.
>
> How can I get the right column to wrap?
More information about the reportlab-users
mailing list