title: How to Repeat Table Column Headings over Page Breaks in PDF output from ReportLab
body: <p>I'm using ReportLab to write tables in PDF documents and am very pleased with the results (despite not having a total grasp on flowables just yet).</p>
  
  <p>However, I have not been able to figure out how to make a table that spans a page break have its column headings repeated.</p>
  
  <p>The code below creates a test.pdf in C:\Temp that has a heading row followed by 99 rows of data.  </p>
  
  <p>The heading row looks great on the first page but I would like that to repeat at the top of the second and third pages.</p>
  
  <p>I'm keen to hear of any approaches that have been used to accomplish that using the SimpleDocTemplate.</p>
  
  <pre class="lang-py prettyprint-override"><code>from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, Frame, Spacer
  from reportlab.lib import colors
  from reportlab.lib.units import cm
  from reportlab.lib.pagesizes import A3, A4, landscape, portrait
  from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
  from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
  from reportlab.pdfgen import canvas
  
  pdfReportPages = "C:\\Temp\\test.pdf"
  doc = SimpleDocTemplate(pdfReportPages, pagesize=A4)
  
  # container for the "Flowable" objects
  elements = []
  styles=getSampleStyleSheet()
  styleN = styles["Normal"]
  
  # Make heading for each column
  column1Heading = Paragraph("&lt;para align=center&gt;COLUMN ONE HEADING&lt;/para&gt;",styles['Normal'])
  column2Heading = Paragraph("&lt;para align=center&gt;COLUMN TWO HEADING&lt;/para&gt;",styles['Normal'])
  row_array = [column1Heading,column2Heading]
  tableHeading = [row_array]
  tH = Table(tableHeading, [6 * cm, 6 * cm])            # These are the column widths for the headings on the table
  tH.hAlign = 'LEFT'
  tblStyle = TableStyle([('TEXTCOLOR',(0,0),(-1,-1),colors.black),
                         ('VALIGN',(0,0),(-1,-1),'TOP'),
                         ('BOX',(0,0),(-1,-1),1,colors.black),
                         ('BOX',(0,0),(0,-1),1,colors.black)])
  tblStyle.add('BACKGROUND',(0,0),(-1,-1),colors.lightblue)
  tH.setStyle(tblStyle)
  elements.append(tH)
  
  # Assemble rows of data for each column
  for i in range(1,100):
      column1Data = Paragraph("&lt;para align=center&gt; " + "Row " + str(i) + " Column 1 Data" + "&lt;/font&gt; &lt;/para&gt;",styles['Normal'])
      column2Data = Paragraph("&lt;para align=center&gt; " + "Row " + str(i) + " Column 2 Data" + "&lt;/font&gt; &lt;/para&gt;",styles['Normal'])
      row_array = [column1Data,column2Data]
      tableRow = [row_array]
      tR=Table(tableRow, [6 * cm, 6 * cm])   
      tR.hAlign = 'LEFT'
      tR.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,-1),colors.white),
                              ('TEXTCOLOR',(0,0),(-1,-1),colors.black),
                              ('VALIGN',(0,0),(-1,-1),'TOP'),
                              ('BOX',(0,0),(-1,-1),1,colors.black),
                              ('BOX',(0,0),(0,-1),1,colors.black)]))
      elements.append(tR)
      del tR
  
  elements.append(Spacer(1, 0.3 * cm))
  
  doc.build(elements)
  </code></pre>