[reportlab-users] Mixed column document - tables or frames?

Robin Becker robin at reportlab.com
Thu Jun 23 05:35:01 EDT 2016


On 22/06/2016 22:17, Angus Dickey via reportlab-users wrote:
> Hi,
>
> I have been looking for a solution to this for a while and tried a couple different things with no luck, so I thought I would try the mailing list.
>
> I am trying to use ReportLab to create a pdf with a full width section (containing a flowable paragraph) at the start, a two column section in the middle, and another full width section at the end. Each of the sections can be variable length.
>
It's not exactly clear who should do the flow control in the mixed single 
column, two column and single column story.

When you switch to the two column layout do you have two stories ie for the left 
and right columns or do you have a single story that you want to spread over the 
two columns?

Anyhow I think for either case if you want nice results you need to establish 
the length of the two column layout. In a simple python context that means 
laying out the two column bit twice once the figure out how much space is needed 
and the second time to do the actual final positioning. There are of course 
other issues eg how much space is left on the page when the two column stuff is 
about to start and whether you should start or throw a page first. Doing a float 
insertion is currently quite hard for reportlab. We do have ways to see what 
happens after each flowable is handled and that may be useful.


> The first method I tried was using SimpleDocTemplate with a paragraph flowable at the top, a two column table flowable in the middle, and another paragraph flowable at the bottom. The issue here is that the table cells (really only two of them, left & right) contain a paragraph flowable of unknown length. If this paragraph is too big it will either be moved to the next page or cause a LayoutError if the cell is too big to fit on a single page. I saw another post to this mailing list about a similar issue which suggested breaking up the paragraph and putting it into multiple cells, is this the only option for using a table?
>
I have performed hacky solutions with both table and frame change approaches. 
Almost aways we measure the required space first and use the  DocIf/DocExec 
flowables to do nasty things.


> The second method I tries was using a regular BaseDocTemplate with multiple frames, but I can only get this to work by creating page templates that will always give me at least a three page document (single column, double column, single column) when the whole thing could fit on one page. Is there a way to make frames work where they switch mid-page?
>
> Are there any other options?
>
>
> Thanks for any help,
>
> Angus


--
Robin Becker


More information about the reportlab-users mailing list