I\'m generating some pdf files using reportlab. I have a certain section that is repeated. It contains of a header and a table:
Story.append(Paragrap
You can try to put them together in a KeepTogether
flowable, like so:
Story.append(KeepTogether([Paragraph(header_string, styleH), table])
However be aware that, last I checked, the implementation was not perfect and would still split up items too frequently. I know it does a good job of keeping a single flowable together that would otherwise split, like if you were to say:
Story.append(KeepTogether(Paragraph(header_string, styleH))
then that paragraph would not get split unless it was impossible for it not to be.
If KeepTogether
doesn't work for you, I'd suggest creating a custom Flowable
with your paragraph and table inside it and then during layout make sure your custom Flowable
subclass does not allow itself to be split up.