Add page numbers to a PDF document
pdfnumbering builds on pypdf and fpdf2 to make it easy to stamp page numbers to a PDF document, and provides a convenient CLI tool to do so.
Installation
Install the published version from PyPI:
python -m pip install pdfnumbering
Or the development version from GitHub:
python -m pip install git+https://github.com/mikmart/pdfnumbering.git
Usage
Package
import sys
from pdfnumbering import PdfNumberer
from pypdf import PdfWriter
INPUT_FILE = sys.argv[1]
OUTPUT_FILE = sys.argv[2]
numberer = PdfNumberer()
document = PdfWriter(clone_from=INPUT_FILE)
numberer.add_page_numbering(document.pages)
document.write(OUTPUT_FILE)
Command line interface
$ pdfnumbering --help
usage: pdfnumbering [-h] [-v] [--first-number N] [--ignore-pages [PAGE ...]]
[--skip-pages [PAGE ...]] [--stamp-format STRING] [--font-size PT]
[--font-family NAME] [--text-color HEX] [--text-align {left,center,right}]
[--text-position X Y] [--page-margin X Y] [-o OUTPUT]
FILE
Stamp pages in a PDF document with page numbers.
positional arguments:
FILE the input PDF file to stamp
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-o OUTPUT, --output OUTPUT
destination to write output to
numbering options:
--first-number N number to start counting from (default: 1)
--ignore-pages [PAGE ...]
pages that should not be counted
--skip-pages [PAGE ...]
pages that should not be stamped
--stamp-format STRING
format string for stamp text, formatted with page number and page
count (default: "{}")
styling options:
--font-size PT font size in points (default: 32)
--font-family NAME font family name (default: Helvetica)
--text-color HEX hexadecimal color code (default: #ff0000)
placement options:
--text-align {left,center,right}
horizontal alignment of page numbers (default: left)
--text-position X Y position of page numbers, in points (default: 0 0)
--page-margin X Y margin at the page edges, in points (default: adapts to font size)
Metadata
Release files for pdfnumbering 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pdfnumbering-0.1.1.tar.gz | 5.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pdfnumbering-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.6 kB
Release files / pdfnumbering-0.1.1.tar.gz
| Download URL | pdfnumbering-0.1.1.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac4d42a9b872edc4ac82d1a3c0f3b29c7ecb67b8dee74e09ea6e74ccd98556dd
|
|
BLAKE2b-256 checksum How to use checksums |
8cfef2f7b9746b383c38908447b7404d1cdfb2bc68e56946c00de3a708c11992
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / pdfnumbering-0.1.1-py3-none-any.whl
| Download URL | pdfnumbering-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b08fb836e9184707d4ab034158e635042ae461af55b86cad484526835a596295
|
|
BLAKE2b-256 checksum How to use checksums |
44669fbbc47c0aca9ee88ffc4d6f6fff3d3e9554518fa13a6e4e87962c11dfac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for pdfnumbering 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.