Showing page count with ReportLab

后端 未结 3 1806
攒了一身酷
攒了一身酷 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:00

    I was able to implement the NumberedCanvas approach from ActiveState. It was very easy to do and did not change much of my existing code. All I had to do was add that NumberedCanvas class and add the canvasmaker attribute when building my doc. I also changed the measurements of where the "x of y" was displayed:

    self.doc.build(pdf)
    

    became

    self.doc.build(pdf, canvasmaker=NumberedCanvas) 
    

    doc is a BaseDocTemplate and pdf is my list of flowable elements.

提交回复
热议问题