[reportlab-users] Table Height problem
Shayan Raghavjee
reportlab-users@reportlab.com
Fri, 27 Aug 2004 17:03:28 +0200
This is a multi-part message in MIME format.
--------------080204000308060905080707
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
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
>
--------------080204000308060905080707
Content-Type: text/plain;
name="PDFTest2.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="PDFTest2.py"
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])
--------------080204000308060905080707
Content-Type: application/pdf;
name="testme.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="testme.pdf"
JVBERi0xLjMNCiWTjIueIFJlcG9ydExhYiBHZW5lcmF0ZWQgUERGIGRvY3VtZW50IGh0dHA6
Ly93d3cucmVwb3J0bGFiLmNvbQ0KJSAnQmFzaWNGb250cyc6IGNsYXNzIFBERkRpY3Rpb25h
cnkgDQoxIDAgb2JqDQolIFRoZSBzdGFuZGFyZCBmb250cyBkaWN0aW9uYXJ5DQo8PCAvRjEg
MiAwIFINCiAvRjIgMyAwIFIgPj4NCmVuZG9iag0KJSAnRjEnOiBjbGFzcyBQREZUeXBlMUZv
bnQgDQoyIDAgb2JqDQolIEZvbnQgSGVsdmV0aWNhDQo8PCAvQmFzZUZvbnQgL0hlbHZldGlj
YQ0KIC9FbmNvZGluZyAvV2luQW5zaUVuY29kaW5nDQogL05hbWUgL0YxDQogL1N1YnR5cGUg
L1R5cGUxDQogL1R5cGUgL0ZvbnQgPj4NCmVuZG9iag0KJSAnRjInOiBjbGFzcyBQREZUeXBl
MUZvbnQgDQozIDAgb2JqDQolIEZvbnQgVGltZXMtUm9tYW4NCjw8I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