Table split Overlap Page Header

MOHAMED BLACK <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <CAO+fUhtofwNhGHM35AKBxpfWp1FoR8vkXk6GHFBCemmnGPWdkw@mail.gmail.com>
Hi,
I'm new to reportlab world so may be this is easy question but i couldn't
find any useful information after digging the mailing list and Google

so my problem is when a table split automatically it overlap my page header
i managed this overlap in first page by adding Spacer
but i have no clue how to do it for the auto splited table pages

here is a demo of what i mean it appear  in page No:2


Test.py
=======
from io import BytesIO

from reportlab.lib import colors
from reportlab.platypus import SimpleDocTemplate,Table,TableStyle,Spacer
from reportlab.lib.pagesizes import A4,landscape
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont

pdfmetrics.registerFont(TTFont("arial",'arial.ttf'))

PageWidth,PageHight=landscape(A4)
buffer=BytesIO()
PdfDoc=SimpleDocTemplate(buffer,pagesize=(PageWidth,PageHight),showBoundary=0,
    rightMargin=18,leftMargin=18,topMargin=18,bottomMargin=32)

PageHeader1="PageHeader1"
PageHeader2="PageHeader2"
(PageHeader1FontName,PageHeader1FontSize)=('arial',14)
(PageHeader2FontName,PageHeader2FontSize)=('arial',14)

TableHeaderColsName =["1","2","3","4","5","6","7","8","9"]
TableHeaderColsWidth=[40,40,40,40,40,40,40,25,40]

AllRows = []
for i in range(1,50):
    AllRows.append(["A","B","C","D","E","F","G","H","I"])

AllTableData=[TableHeaderColsName,]+AllRows

def myFirstPage(canvas,doc):
    canvas.saveState()

    canvas.setFont(PageHeader1FontName,PageHeader1FontSize)
    canvas.drawCentredString(PageWidth/2,PageHight-27,PageHeader1)

    canvas.setFont(PageHeader2FontName,PageHeader2FontSize)
    canvas.drawCentredString(PageWidth/2,PageHight-55,PageHeader2)

    #Some More Stuff

    canvas.restoreState()

def myLaterPages(canvas,doc):
    canvas.saveState()

    canvas.setFont(PageHeader1FontName,PageHeader1FontSize)
    canvas.drawCentredString(PageWidth/2,PageHight-27,PageHeader1)

    canvas.setFont(PageHeader2FontName,PageHeader2FontSize)
    canvas.drawCentredString(PageWidth/2,PageHight-55,PageHeader2)

    #Some Diffrent Stuff

    canvas.restoreState()

tblStyle=TableStyle([('TEXTCOLOR',(0,0),(-1,-1),colors.black),
   ('VALIGN',(0,0),(-1,-1),'MIDDLE'),
   ('ALIGNMENT',(0,0),(-1,-1),'CENTER'),
   ('LINEBELOW',(0,0),(-1,-1),1,colors.black),
   ('BOX',(0,0),(-1,-1),1,colors.black),
   ('INNERGRID',(0,0),(-1,-1),.5,colors.black),
   ('FONT',(0,0),(-1,-1),'arial',10),
   ('FONT',(0,0),(-1,0),'arial',10)
   ])
tblStyle.add('BACKGROUND',(0,0),(-1,0),colors.lightblue)


MyTable=Table(AllTableData,colWidths=TableHeaderColsWidth,
    rowHeights=[30,]+([15]*(len(AllTableData)-1)),
    repeatRows=1)
MyTable.hAlign = 'CENTER'

MyTable.setStyle(tblStyle)

Elements=[]
Elements.append(Spacer(0,54))
Elements.append(MyTable)

PdfDoc.build(Elements,onFirstPage=myFirstPage,onLaterPages=myLaterPages)

x=buffer.getvalue()
with open("doc0.pdf",'wb') as f:
    f.write(x)

print("End")


thanks in advance
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.