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

Saketh Bhamidipati saketh.bhamidipati at gmail.com
Fri Aug 25 20:35:36 EDT 2006


On 8/25/06, John Pywtorak <jpywtora at calpoly.edu> wrote:
>
> The problem with your second issue (ValueError exception below) I
> believe is the for loops creating the headings and texts arrays and then
> the line:
> data = (headings, texts), (headings, texts)
> Take a look at data it is created wrong for Table.  I think you are
> getting something like
> data = (((Paragraph, ...), (Paragraph, ...)), ((Paragraph, ...),
> (Paragraph, ...)))
> It needs to be
> data = (
> #Row 0
> ('Col 0', 'Col 1', '...'),
> #Row 1
> ('Col 0', 'Col 1', '...'),
> #Row ...
> )
>
> Hope this helps.
>
> Saketh Bhamidipati wrote:
> ...
> > That explains the lack of wrapping.
> >
> > I'm almost there, I just have two more problems to fix and then it's
> > perfect.
> >
> > First of all, the column on the right doesn't shrink to the left. I want
> > it to be 6 inches wide, with the column on the left being 1.5 inches
> > wide, and both on the paper. But when I changed the colWidth from 7 *
> > inch to 6 * inch, the left column moves to the right. See the attached
> > PDFs for examples of the problem.
> >
> >         def __init__(self, filename, title, author):
> >             self.title = title
> >             self.author = author
> >             self.doc = NotalonTemplate(filename, title, author)
> >             self.story = []
> >             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'),
> >                 ('VALIGN', (0, 0), (-1, -1), 'TOP')])
> >
> >         def addTextAndHeading(self, text, heading):
> >             texts = []
> >             headings = []
> >
> >             for line in text.strip().splitlines():
> >                 texts.append(Paragraph(bullet(line),
> >     style=styles["Normal"]))
> >
> >             for line in heading.strip().splitlines():
> >                 headings.append(Paragraph(line, style=styles["Normal"]))
> >
> >             data = (headings, texts), (headings, texts)
> >
> >             # Here's the troublesome line
> >             self.story.append(Table(data, colWidths=(1.5 * inch, 7 *
> inch),
> >                               style=self.style))
> >
> >
> >
> > Second, I can't append one row at a time for some reason. If I set the
> > data variable to (headings, texts), then I get an error which says:
> >
> >     ValueError: <Table at 18562824 2 rows x 1 cols> with cell(0,0)
> >     containing
> >     '<Paragraph at 0x11a7238>heading heading heading headin' data error
> >     - 1 columns in data but 2 in grid
> >
> >
> > Thanks.
> >
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
Actually, I needed to do this:

data = [(headings, texts)]

I'm still having that alignment issue, though.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://two.pairlist.net/pipermail/reportlab-users/attachments/20060825/ca7affce/attachment.html


More information about the reportlab-users mailing list