Showing page count with ReportLab

后端 未结 3 1793
攒了一身酷
攒了一身酷 2020-12-15 23:48

I\'m trying to add a simple \"page x of y\" to a report made with ReportLab.. I found this old post about it, but maybe six years later something more straightforward has em

3条回答
  •  伪装坚强ぢ
    2020-12-16 00:10

    use doc.multiBuild

    and in the page header method (defined by "onLaterPages="):

    global TOTALPAGES
    if doc.page > TOTALPAGES:
        TOTALPAGES = doc.page
    else:
        canvas.drawString(270 * mm, 5 * mm, "Seite %d/%d" % (doc.page,TOTALPAGES))
    

提交回复
热议问题