Reportlab Error after page break
<p>I am designing a two page form to be printed duplex.  After I add a pagebreak, I get the following error:</p>

<pre><code>    File "f:\Dropbox\pms\pms_reports.py", line 450, in &lt;module&gt;
  a = Key_card1()
File "f:\Dropbox\pms\pms_reports.py", line 441, in __init__
  doc.build(elements)
File "c:\Python34\Lib\site-packages\reportlab\platypus\doctemplate.py", line 1171, in build
  BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
File "c:\Python34\Lib\site-packages\reportlab\platypus\doctemplate.py", line 927, in build
  self.handle_flowable(flowables)
File "c:\Python34\Lib\site-packages\reportlab\platypus\doctemplate.py", line 775, in handle_flowable
  self.handle_keepWithNext(flowables)
File "c:\Python34\Lib\site-packages\reportlab\platypus\doctemplate.py", line 742, in handle_keepWithNext
  while i&lt;n and flowables[i].getKeepWithNext(): i += 1

builtins.TypeError: getKeepWithNext() missing 1 required positional argument: 'self'
</code></pre>

<p>Here is my code:</p>

<pre><code>from reportlab.lib.pagesizes import A4, landscape
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, PageBreak
from reportlab.lib.styles import getSampleStyleSheet

    class Key_card1():
    def __init__(self, start_date=datetime.now(), room="1", 
           end_date=datetime.now()+timedelta(days=1), password = "999999"):
        stylesheet = getSampleStyleSheet()
        doc = SimpleDocTemplate("key_card.pdf", pagesize=A4)

        if password == "999999":
            password = str(random.randint(10000,99999))

        roomno = "Room" + room
        w_text = []
        w_text.append(Paragraph("To use the wireless broadbandâ¦:",stylesheet["BodyText"]))
        w_text.append(Paragraph("User id: &lt;b&gt;" + roomno + "&lt;/b&gt;", stylesheet["BodyText"]))
        w_text.append(Paragraph("Password: &lt;b&gt;" + password + "&lt;/b&gt;", stylesheet["BodyText"]))

        message_text = []
        message_text.append(Paragraph("Our current menus ...", stylesheet["BodyText"]))
        message_text.append(Paragraph("Our restaurant can get very busy ...",stylesheet["BodyText"])) 
        message_text.append(Paragraph("Your shower has a safety device to...", stylesheet["BodyText"]))
        message_text .append(Paragraph("Please do not hesitate to call...",stylesheet["BodyText"]))


        elements=[]
        table_data = [(w_text, message_text)]
        the_table = Table(table_data)
        the_table.setStyle(TableStyle([('VALIGN',(0,0),(-1,-1),'MIDDLE')]))
        elements.append(the_table)
        elements.append(PageBreak)

        #Cover page
        logo= "y:\marketing\priory_master_logo bw.jpg"
        im = Image(logo, 3*cm, 1.258*cm)

        cover_data = []
        cover_data.append(im)
        cover_data.append(Paragraph("Room number : " + room, stylesheet["BodyText"]))
        left_cell =[]
        left_cell.append(Paragraph(" ", stylesheet["BodyText"]))


        table_data1 = [(left_cell, cover_data)]
        the_table1 = Table(table_data1)
        the_table1.setStyle(TableStyle([('VALIGN',(0,0),(-1,-1),'MIDDLE')]))
        elements.append(the_table1)


        doc.build(elements)
</code></pre>

<p>I tried modifying the Reportlab modules but I was not successful.  Anybody have any ideas?</p>

<p>I have tried to understand the error and i guess there is problem in
<code>doc = SimpleDocTemplate("key_card.pdf", pagesize=A4)</code>.The problem may be the argument "key_card.pdf". I'm not sure</p>

<p>Edit: Maybe, <code>BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)</code> problem is about "flowables" argument which is connected to elements in doc.build(elements)</p>

<p>SOLUTION -> elements.append(PageBreak) should be elements.append(PageBreak())</p>

python reportlab