gpt4 book ai didi

报告实验室布局错误 : Flowable Spacer too large

转载 作者:行者123 更新时间:2023-12-01 00:44:31 25 4
gpt4 key购买 nike

我正在使用 reportlab 3.2.0。

SPACER = Spacer(0, 10)
buff = BytesIO()
doc = SimpleDocTemplate(buff, rightMargin=0.2 * inch,
leftMargin=0.2 * inch,\
topMargin=100, bottomMargin=68)
elements = []
# here add elements
elements.append(SPACER)
# here add more elements
doc.build(elements)

每当空间接近页面底部时,我都会收到此错误:
File "/venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py", line 1171, in build
BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
File "/venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py", line 927, in build
self.handle_flowable(flowables)
File "/venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py", line 829, in handle_flowable
raise LayoutError(ident)
LayoutError: Flowable <Spacer at 0x4c87d40 frame=normal>...(0 x 10) too large on page 2 in frame 'normal'(554.475590551 x 661.88976378) of template 'Later'

有没有办法防止它抛出异常(即忽略空格元素)?

最佳答案

这是 Spacer 的一个快速实现,它使用您分配给它的高度或当前页面上剩余的空间中较小的一个。

class ConditionalSpacer(Spacer):

def wrap(self, availWidth, availHeight):
height = min(self.height, availHeight-1e-8)
return (availWidth, height)

您可以像 Spacer 一样使用它。

关于报告实验室布局错误 : Flowable Spacer too large,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35494584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com