I have a pdf I'm generating with reportlab. I'm rendering the document using the SimpleDocTemplate
The first n pages are all the same but the last one is completely different (formatting and content) consisting of an image that should take up the whole page. When adding the image as a Flowable
element I get an out of bounds error because it's too large for the defined page boundaries.
I can render it fine using the canvas but then it appears on every page - does anyone have a suggestion for the best way to approach this?
Thanks
If you know the last page number:
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)
If you don't know the total page number, check out this, but I think they did not use SimpleDocTemplate...