[reportlab-users] Re: Getting the number of lines in a frame

Saketh Bhamidipati saketh.bhamidipati at gmail.com
Wed Aug 23 10:33:35 EDT 2006


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.
> > >
> > >     Perhaps you should say what you try to achieve - there
> > >     may be different ways to achieve your goals without the
> > >     need to count the number of lines.
> > >
> > >     Henning
> > >
> >
> > Henning is right.  Pretend it's HTML!
> >
> > 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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://two.pairlist.net/pipermail/reportlab-users/attachments/20060823/92a6a81f/attachment.html


More information about the reportlab-users mailing list