Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7855469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:23:46+00:00 2026-06-02T20:23:46+00:00

I’m generating a table that is long enough to go onto second page. What

  • 0

I’m generating a table that is long enough to go onto second page. What I would like to achieve is to SPAN 4 rows on the second page. I do it using the follwing code in the TableStyle.

('SPAN', (0,38), (0,41))

Span for two rows works though. (‘SPAN’, (0,38), (0,39))

Here’s a code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from reportlab.platypus import SimpleDocTemplate, Table, LongTable, TableStyle, BaseDocTemplate, Frame, Paragraph, NextPageTemplate, PageTemplate
from reportlab.lib.pagesizes import letter, inch
from reportlab.lib import colors

def testPdf():
    doc = BaseDocTemplate("testpdf.pdf",pagesize=letter,
                        rightMargin=72,leftMargin=72,
                        topMargin=72,bottomMargin=18, showBoundary=True)
    width, height = letter
    print width 
    print height

    elements = []
    datas = []
    for x in range(1,50):
        datas.append(
            [x,x+1]
        )
    t=LongTable(datas)

    tTableStyle=[
        ('SPAN', (0,38), (0,41)),
        ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
        ('BOX', (0,0), (-1,-1), 0.25, colors.black),
    ]
    t.setStyle(TableStyle(tTableStyle))
    elements.append(t)

    frameT = Frame(doc.leftMargin, doc.bottomMargin, doc.width, doc.height, id='normal')

    doc.addPageTemplates([PageTemplate(id='OneCol',frames=frameT)])

    doc.build(elements)

if __name__ == '__main__':
    testPdf()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:23:49+00:00Added an answer on June 2, 2026 at 8:23 pm

    I ran your sample code and saw the same problem. For anyone coming along who might be interested, the error that results is:

    Traceback (most recent call last):
      File "./test.py", line 39, in <module>
        testPdf()
      File "./test.py", line 36, in testPdf
        doc.build(elements)
      File "/usr/local/greenplum-db/ext/python/lib/python2.6/site-packages/reportlab/platypus/doctemplate.py", line 880, in build
        self.handle_flowable(flowables)
      File "/usr/local/greenplum-db/ext/python/lib/python2.6/site-packages/reportlab/platypus/doctemplate.py", line 763, in handle_flowable
        if frame.add(f, canv, trySplit=self.allowSplitting):
      File "/usr/local/greenplum-db/ext/python/lib/python2.6/site-packages/reportlab/platypus/frames.py", line 159, in _add
        w, h = flowable.wrap(aW, h)
      File "/usr/local/greenplum-db/ext/python/lib/python2.6/site-packages/reportlab/platypus/tables.py", line 1113, in wrap
        self._calc(availWidth, availHeight)
      File "/usr/local/greenplum-db/ext/python/lib/python2.6/site-packages/reportlab/platypus/tables.py", line 587, in _calc
        self._calc_height(availHeight,availWidth,W=W)
      File "/usr/local/greenplum-db/ext/python/lib/python2.6/site-packages/reportlab/platypus/tables.py", line 553, in _calc_height
        spanFixDim(H0,H,spanCons,lim=hmax)
      File "/usr/local/greenplum-db/ext/python/lib/python2.6/site-packages/reportlab/platypus/tables.py", line 205, in spanFixDim
        t = sum([V[x]+M.get(x,0) for x in xrange(x0,x1)])
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
    

    Sort answer: this is a bug in ReportLab and you’ll need to report it to the developers.

    Long answer: I’ve seen problems with splitting before. There were (and apparently still are) situations that confuse the algorithm when splitting is plainly possible but the algorithm ends up throwing an error because it can’t figure out which page to put it on. It can happen at weird times when you wouldn’t expect it, and I know of no especially good work around other than to manually split things yourself (or to wrap content in KeepTogether flowables, but that won’t work in your situation).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.