Add page numbers
add_page_numbersWrite page numbers or custom headers/footers onto selected or all PDF pages, placing searchable text at a chosen corner, and save the result as a new PDF.
Instructions
Writes page numbers, or a header/footer such as "Confidential - Page {n} of {total}", onto every page or the chosen pages of a PDF and saves the result as a new PDF. The text is placed at the chosen corner or edge, and stays real, searchable text. For a large diagonal stamp across the page, use add_watermark. The original is not changed, and an existing output file is only replaced with overwrite: true. Encrypted PDFs cannot be saved.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path of the PDF. | |
| color | No | Text colour (default dark grey), as #rrggbb. | |
| pages | No | Pages as 1-based numbers and ranges, e.g. "1-3,5". All pages when omitted; a page outside the document is an error. | |
| start | No | Number of the first page (default 1). | |
| format | No | Text with {n} for the page number and {total} for the page count (default "{n}"). | |
| margin | No | Distance from the page edge in points (default 24). | |
| output | Yes | Absolute path of the new PDF. If the file exists, the call fails unless overwrite is true. | |
| password | No | Password, if the PDF is encrypted. Without it an encrypted PDF cannot be opened; with it, it can be read, but tools that write a new PDF cannot save it. | |
| position | No | Default bottom-center. | |
| font_size | No | Default 10. | |
| overwrite | No | Allow replacing an existing file (default false). |