Secret to laying out data with reportlab.platypus
Posted by Gene at
21:03 on Tue 23 Mar 2010
-- 0 Comments
If you want to build PDF's with a python program, then ReportLab software is what you need. Go get it. Set aside some time to read the manual: Reportlab Userguide.
If you have read up on ReportLabs and specifically Playpus, you'll probably think it's hugely powerful, but slightly confusing. The manual does a pretty good job, but I think it leaves out one important point.
When you are laying out your frames, they go across the page, and wrap if necessary. It is not natural to control their exactly placement, and it is not clear how to force a break in the layout. Here's an example
:
:
elements.append(Paragraph('Innovating Programming,some-style))
elements.append(Paragraph('Picante Solutions',some-other-style))
:
:
When building these elements, they will be next to each other, assuming the styles are not too wide.
If you want them to be on their own lines, you need a line break. It is done like this
:
elements.append(Paragraph('Innovating Programming,some-style))
elements.append(Paragraph('Picante Solutions',some-other-style))
:
:
elements.append(FrameBreak())
That is it. It took me a bit of searching and I don't want to forget it, so I'm adding it here.
References
