ReportLab 中的动态垫片
我使用 Platypus 自动生成一个包含动态内容的 PDF 文件。
这意味着文本内容的长度(直接位于 pdf 文件的底部)可能会发生变化。
但是,如果内容太长,可能会出现分页的情况。 这是因为我使用“静态”间隔器:
s = Spacer(width=0, height=23.5*cm)
因为我总是只想只有一页,所以我需要以某种方式动态设置间隔器的高度,以便占用页面上剩余的空间的“其余”部分由垫片作为其高度。
现在,我如何获得页面上剩余的“其余”高度?
I'm automatically generating a PDF-file with Platypus that has dynamic content.
This means that it might happen that the length of the text content (which is directly at the bottom of the pdf-file) may vary.
However, it might happen that a page break is done in cases where the content is too long.
This is because i use a "static" spacer:
s = Spacer(width=0, height=23.5*cm)
as i always want to have only one page, I somehow need to dynamically set the height of the Spacer, so that the "rest" of the space that is left on the page is taken by the Spacer as its height.
Now, how do i get the "rest" of height that is left on my page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在reportlab库中嗅了一下,发现了以下内容:
基本上,我决定使用一个框架来打印可流动的内容。 f._aH 返回框架的高度(我们也可以手动计算)。减去通过包装获得的其他两个可流动物体的高度,我们得到剩余的高度,即间隔物的高度。
经过测试并且工作正常。
I sniffed around in the reportlab library a bit and found the following:
Basically, I decided to use a frame into which the flowables will be printed. f._aH returns the height of the Frame (we could also calculate this by hand). Subtracting the heights of the other two flowables, which we get through wrap, we get the remaining height which is the height of the Spacer.
tested and works fine.
据我所知,您想要页脚,对吗?
那么你应该这样做:
As far as i can see you want to have footer, right?
Then you should do it like: