如何在 reportlab 中对对象进行分组,以便它们在新页面中保持在一起 [英] how to group objects in reportlab, so that they stay together across new pages

查看:55
本文介绍了如何在 reportlab 中对对象进行分组,以便它们在新页面中保持在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 reportlab 生成一些 pdf 文件.我有一个重复的部分.它包含一个标题和一个表格:

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(Paragraph(header_string, styleH))
            Story.append(table) 

我如何将段落与表格分组(在乳胶中我会将它们放在相同的环境中),以便在页面刹车的情况下,段落和表格保持在一起?目前,段落有时会浮动在一页的末尾,而表格则从下一页的顶部开始.

How can I group the paragraph with the table (in latex I would put them into the same environment) so that in case of a page brake, the paragraph and table stay together? Currently the paragraph sometimes floats at the end of one page and the table starts on top of the next page.

推荐答案

这是我通过 reportlab 源代码找到的解决方案:

this is the solution that I found going through the reportlab source code:

paragraph = Paragraph(header_string, styleH)
paragraph.keepWithNext = True
Story.append(paragraph)
Story.append(table)

这篇关于如何在 reportlab 中对对象进行分组,以便它们在新页面中保持在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆