gpt4 book ai didi

python - 添加整页图像作为reportlab的最后一页

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

我有一个用reportlab生成的pdf文件。我正在使用 SimpleDocTemplate 渲染文档。前 n 页都是相同的,但最后一页完全不同(格式和内容),由应占据整个页面的图像组成。将图像添加为 Flowable 元素时,我收到越界错误,因为它对于定义的页面边界来说太大。

我可以使用 Canvas 将其渲染得很好,但随后它会出现在每个页面上 - 有人对解决此问题的最佳方法有建议吗?

谢谢

最佳答案

如果您知道最后页码:

def onLaterPages(self, doc, canvas):
if doc.page == TOTAL_PAGES:
canvas.saveState()
canvas.drawImage(filename, 0, 0, *pagesize)
canvas.restoreState()

# and when calling doc.build
doc.build(..., onLaterPages=onLaterPages)

如果您不知道总页数,请查看this ,但我认为他们没有使用 SimpleDocTemplate...

关于python - 添加整页图像作为reportlab的最后一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10320372/

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