[reportlab-users] Reducing the margin of a table

Claudio Battaglino c.battaglino at icube.it
Wed Jun 29 07:38:59 EDT 2005


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



Robin Becker wrote:
> Claudio Battaglino wrote:
> 
>> Hi,
>> I'd like to generate a page with a single table with margin = 0.
>> That is the table should fill all the page.
>> I tried it and the result is in the attachment.
>> As you can see I don't have a null margin and between the table and the
>> border of the page I've an empty space.
>> How can I have a table that fills all the page?
>>
> ......
> Unfortunately for reasons bets know only to an earlier iteration of 
> myself it seems that Frames come with a built in set of paddings and in 
> SimpleDcocTemplate there's no easy way to get at them. A way round that 
> is to define your own class and fix up the paddings prior to use eg
> 
> ##########
> 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])
> ########
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: top_margin.pdf
Type: application/pdf
Size: 25338 bytes
Desc: not available
Url : http://two.pairlist.net/pipermail/reportlab-users/attachments/20050629/5c70d1a2/top_margin-0001.pdf


More information about the reportlab-users mailing list