I am trying to generate a pdf that will look like this:
Here is my code:
doc = doc = SimpleDocTemplate(invoice_name)
flowable = []
flowable.append(Paragraph(invoice_name))
flowable.append(Paragraph(invoice_number))
flowable.append(Paragraph(invoice_date))
flowable.append(Spacer(1,4))
t = Table(table_data)
flowable.append(t)
flowable.append(Spacer(1,4))
flowable.append(Paragraph(comment_and_amount))
doc.build(flowable)
But I get this error: 'list' object has no attribute 'getKeepWithNext'
I see a lot of minor typos in this code, but the general form of the code is correct.
I have fixed all the typos, added the imports and added some data to make a working example:
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table
invoice_name = "Test"
doc = SimpleDocTemplate("test.pdf")
flowable = []
flowable.append(Paragraph(invoice_name))
flowable.append(Paragraph("1234"))
flowable.append(Paragraph("12/12/2023"))
flowable.append(Spacer(1,4))
table_data= [['00', '01', '02', '03', '04'],
['10', '11', '12', '13', '14'],
['20', '21', '22', '23', '24'],
['30', '31', '32', '33', '34']]
t = Table(table_data)
flowable.append(t)
flowable.append(Spacer(1,4))
flowable.append(Paragraph("comment_and_amount"))
doc.build(flowable)