[reportlab-users] Table Height problem

Shayan Raghavjee reportlab-users@reportlab.com
Wed, 01 Sep 2004 11:06:28 +0200


Hi again,

Any thoughts on my last mail? I've tried fiddling around, but I'm still 
lost as to why it's messing up?

Thanks,
Shayan Raghavjee

Shayan Raghavjee wrote:

> Hi again,
>
> Arr, I thought I had it sorted, but spanning is still giving me wierd 
> results.
>
> I've included a test case, and the pdf I get.
>
> Thanks,
> Shayan Raghavjee
>
> andy@reportlab.com wrote:
>
>> We need more information to reproduce this.  Can you send an output 
>> file and/or some code examples?  The best of all would be a slimmed 
>> down script which reproduces the problem, plus the PDF it produces.
>>
>> Best Regards,
>>
>> Andy Robinson
>> CEO/Chief Architect
>> RepoortLab Europe Ltd.
>> tel +44 20 8544 8049
>>
>> -----Original Message-----
>> From: Shayan Raghavjee <shayanr@sjsoft.com>
>> To: reportlab-users@reportlab.com
>> Sent: Wed, 25 Aug 2004 15:37:38 +0200
>> Subject: [reportlab-users] Table Height problem
>>
>> Hi Guys,
>>
>> I haven't had a problem for quite a while, until now sadly.
>>
>> I'm using ReportLab via ModPython, (I don't think the problem has 
>> anything to do with that though), and it's producing wierd tables. 
>> I'm producing a set of tables, a print representation of an HTML form.
>>
>> Basically, there's code that calculates the table widths, which it 
>> does fine, however the height of the rows is the problem. The 1st 2 
>> rows are fine, the 3rd is a little smaller, just a little too small 
>> for the text, and the rows after that are tiny. I don't have any code 
>> that calculates the height of the rows, so I'm not quite sure where 
>> it's gone wrong.
>>
>> I have noticed that it's only if I use a paragraph flowable, if I use 
>> plaintext, it's fine.
>>
>> Any thoughts or suspicions?
>>
>> Thanks,
>> Shayan Raghavjee
>> St. James Software
>> _______________________________________________
>> reportlab-users mailing list
>> reportlab-users@reportlab.com
>> http://two.pairlist.net/mailman/listinfo/reportlab-users 
>> _______________________________________________
>> reportlab-users mailing list
>> reportlab-users@reportlab.com
>> http://two.pairlist.net/mailman/listinfo/reportlab-users
>>
>------------------------------------------------------------------------
>
>from reportlab.platypus import *
>from reportlab.lib.styles import getSampleStyleSheet
>from reportlab.lib.styles import ParagraphStyle
>from reportlab.lib import colors
>from reportlab.rl_config import defaultPageSize
>from reportlab.lib.units import cm
>
>from jToolkit.widgets import widgets
>from jToolkit.widgets import table
>from jLogbook.python import logform
>from jLogbook.python import logreport
>from jLogbook.python import logrecords
>from jToolkit import attachments
>
>tablestyle = [('BOX', (0, 0), (-1, -1), 0.25, colors.black),
>              
>              ('SPAN', (1, 2), (5, 6)),         #I work
>              ('BACKGROUND', (1, 2), (5, 6), colors.orange),
>              
>              ('SPAN', (1, 7), (3, 8)),          #What's wrong with this????
>              ('BACKGROUND', (1,7), (3,8), colors.blue),
>              
>              ('VALIGN', (0,0), (-1,-1), 'TOP'),
>              ('GRID', (0,0), (-1,-1), 0.25, colors.pink)]
>
>
>colwidths = [57.673228346456689,
>             115.34645669291338,
>             57.673228346456689,
>             115.34645669291338,
>             57.673228346456689,
>             115.34645669291338,
>             57.673228346456689,
>             115.34645669291338]
>
>tabledata = [
>    ['Shift', 'This is a key used to generate capital, you can use caps lock. It also could mean a change of some sort.', 'Shift Super', 'Uber administrator de la Fuente', 'Supervisor In', 'A world of hurt, oh yeah! Ahahahaha', 'Date', 'Stardate 1234567890, Grendos IV Mean Time'],
>    ['Area', 'dig', 'Site', 'Central', 'Attachment', '', 'Audit log', ''],
>    ['Message', """We repeat this for the words 'Region', Product'
>        and 'Total', which each span the top 2 rows; and for 'Nprth' and 'South'
>        which span 3 rows.  At the moment each cell's alignment is the default
>        (bottom), so these words appear to have "dropped down"; in fact they
>        are sitting on the bottom of their allocated ranges.  You will just see that
>        all the 'None' values vanished, as those cells are not drawn any more.""", '', '', '', '', 'Active Permits', 'Badges? Wee don need no steeking badges. Andele, Andele, Heppa, Heppa, Yeeehaaa!'],
>    ['', '', '', '', '', '', '', ''],
>    ['', '', '', '', '', '', '', ''],
>    ['', '', '', '', '', '', '', ''],
>    ['', '', '', '', '', '', '', ''],
>    ['Maint Complete', """We repeat this for the words 'Region', Product'
>        and 'Total', which each span the top 2 rows; and for 'Nprth' and 'South'
>        which span 3 rows.  At the moment each cell's alignment is the default
>        (bottom), so these words appear to have "dropped down"; in fact they
>        are sitting on the bottom of their allocated ranges.  You will just see that
>        all the 'None' values vanished, as those cells are not drawn any more.""", '', '', 'Maint On Going', '', '', ''],
>    ['', '', '', '', '', '', '', ''],
>    ['Process Shutdowns', '', '', '', 'Abnormal Operations', 'Ave!', '', ''],
>    ['', '', '', '', '', '', '', '']]
>
>testfile = "c:\\testme.pdf"
>
>tableparagraphs = []
>styles = getSampleStyleSheet()
>
>for row in tabledata:
>    tablerow = []
>    for cell in row:
>        tablerow.append(Paragraph(cell, styles["Normal"]))
>    tableparagraphs.append(tablerow)
>
>table = Table(tableparagraphs, style=tablestyle, repeatRows=1, colWidths=colwidths)
>
>PAGE_HEIGHT = 21 * cm # defaultPageSize[1]
>PAGE_WIDTH = 29.7 * cm # defaultPageSize[0]
>doc = SimpleDocTemplate(filename=testfile,pagesize=(PAGE_WIDTH, PAGE_HEIGHT),\
>                        leftMargin=2*cm,rightMargin=2*cm,topMargin=2*cm,bottomMargin=2*cm)
>doc.build([table])
>