I create PDFs tables with platypus Reportlab. I do not know when the page is full due to dynamic content. How can I check if I am at the end of the page?
Is there any method in the platypus to check the end of the page?
I have a list of companies, and each company has several business units with their own responsibilities.
companies = [('company1', 'businessunit1', 500), ('company1', 'businessunit2',400), ('company2', 'businessunit3',200), ('company2', 'businessunit4', 700), ('company3', 'businessunit5', 800) ]
The above list should generate 3 tables for each company, but if there are several companies in this list that generate several tables and if any table reaches the end of the page that will break.
fields = ['company name', 'business unit name', 'charge'] for i, comp in enumerate(companies): charges = [] document.append(Paragraph("<b>%s</b>" %comp[i][0], STYLES['COMPANY_NAME'])) document.append(Spacer(1, 5)) charges.append(comp[i][0]) charges.append(comp[i][1]) charges.append(comp[i][2]) charges_table = LongTable([fields] + charges, colWidths=(30,150,100)) charges_table.setStyle(TableStyle([ ('BACKGROUND', (0, 0), (-1, 0), colors.gray), ('FONTSIZE', (0, 0), (-1, 0), 6), ('GRID', (0, 0), (-1, -1), 1, colors.gray), ('FONTSIZE', (0, 0), (-1, -1), 7), ('TEXTCOLOR',(0,-1),(-1,-1),'#FF4500'), ]) ) charges_table.hAlign = 'CENTER' document.append(charges_table)