[reportlab-users] Reducing the margin of a table
Claudio Battaglino
c.battaglino at icube.it
Thu Jun 30 04:04:41 EDT 2005
In your example, if you don't specify rowHeights you have a bottom margin.
The User Guide says:
"The rowHeights argument is a sequence of numbers or possibly None,
representing the heights of the rows....A value of None means that the
corresponding row height should be calculated automatically".
The following table, for example, doesn't fill the page.
So I must specify rowHeights.
I thought this was done automatically.
t = Table([['This is a single cell table']],
colWidths=PAGE_WIDTH,
style=TableStyle([
('LEFTPADDING',(0,0),(-1,-1), 0),
('RIGHTPADDING',(0,0),(-1,-1), 0),
('BOX',(0,0),(-1,-1), 0.1, colors.blue),
],
),
)
However I solved the problem specifying rowHeights.
I don't like it but it works.
Thank you very much for your help.
claudio :-)
Robin Becker wrote:
> Claudio Battaglino wrote:
>
>> Thank you for the answer.
>> I tried it, but the problem is that works only for the top margin.
>> I still have a bottom, left and right margin.
>> The result is in the attachment.
>>
>>
>> claudio
>>
>>
>>
> ....the attachment only demonstrates that you're not doing what the
> example does. Without access to the code it will be hard to guess what
> that is.
>
##########
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle,
Paragraph
from reportlab.lib.units import cm
from reportlab.lib import colors
PAGE_WIDTH = 5.5 * cm
PAGE_HEIGHT = 2.2 * cm
t = Table([['This is a single cell table']],
colWidths=PAGE_WIDTH,rowHeights=PAGE_HEIGHT,
style=TableStyle([
('VALIGN',(0,0),(-1,-1),'BOTTOM'),
('ALIGN',(0,0),(-1,-1),'LEFT'),
('LEFTPADDING',(0,0),(-1,-1), 0),
('RIGHTPADDING',(0,0),(-1,-1), 0),
('BACKGROUND', (0,0), (-1,-1), colors.pink),
('BOX',(0,0),(-1,-1), 0.1, colors.blue),
],
),
)
class MySimpleDocTemplate(SimpleDocTemplate):
def addPageTemplates(self,pageTemplates):
'''fix up the one and only Frame'''
if pageTemplates:
f = pageTemplates[0].frames[0]
f._leftPadding=f._rightPadding=f._topPadding=f._bottomPadding=0
#f._reset()
f._geom()
SimpleDocTemplate.addPageTemplates(self,pageTemplates)
MySimpleDocTemplate('tt.pdf',
pagesize=(PAGE_WIDTH, PAGE_HEIGHT),
bottomMargin=0, topMargin=0, rightMargin=0, leftMargin=0,
showBoundary=1).build([t])
########
More information about the reportlab-users
mailing list