---
title: "How do I add page numbers and a footer to every page in ReportLab?"  
description: "How do I add page numbers and a footer to every page in ReportLab?"  
author: "Mikko Lehtonen"  
published: 2026-12-01  
updated: 2026-12-01  
canonical: https://www.mindstick.com/forum/163169/how-do-i-add-page-numbers-and-a-footer-to-every-page-in-reportlab  
category: "python"  
tags: ["python", "ReportLab", "pdf"]  
reading_time: 1 minute  

---

# How do I add page numbers and a footer to every page in ReportLab?

How do I add page numbers like "Page 2 of 10" and a company footer to every page of a PDF made with ReportLab platypus?

## Replies

### Reply by Vaishnavi Sawant

With platypus (SimpleDocTemplate), you draw headers and footers in a page callback function, and use a custom canvas class to get the total page count.

```
from reportlab.pdfgen import canvas

class NumberedCanvas(canvas.Canvas):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.pages = []
    def showPage(self):
        self.pages.append(dict(self.__dict__))
        self._startPage()
```

Then add a save method that loops through the stored pages, updates the canvas state for each, draws the footer text with drawRightString (for example "Page 2 of 10") using the length of self.pages, and calls the parent showPage and save. The ReportLab user guide and many examples show this "NumberedCanvas" pattern in full.

Build the document with doc.build(story, canvasmaker=NumberedCanvas). For a simple footer without the total count, pass onFirstPage and onLaterPages functions to build, and inside them call canvas.drawString at a fixed position near the bottom margin, using canvas.getPageNumber() for the current page.


---

Original Source: https://www.mindstick.com/forum/163169/how-do-i-add-page-numbers-and-a-footer-to-every-page-in-reportlab

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
