Skip to main content

Python library to manipulate PDF page numbers and labels.

Project description


Python library to manipulate PDF page labels

Addpagelabels utility



Install pip if you don't have it already:

$ sudo apt install python3-pip

Install pdfrw:

$ pip3 install --user pdfrw

The script

$ git clone

How to use

Get to the directory where you cloned the script:

$ cd pagelabels-py

Add a new page index to the PDF

This reads the file /tmp/test.pdf, and creates a copy of it with new page labels without deleting the ones that may already exist. The new index will take effect from the 1st page of the PDF, will be composed of uppercase roman numerals, preceded by the string "Intro ", and starting from "V".

Page numbers will be: "Intro V", "Intro VI", "Intro VII", ...

$ ./ --startpage 1 --type "roman uppercase" --prefix "Intro " --firstpagenum 5 --outfile /tmp/new.pdf /tmp/test.pdf

Print usage info

$ ./ -h

This should print:

usage: [-h] [--delete] [--startpage STARTPAGE]
                        [--type {arabic,roman lowercase,roman uppercase,letters lowercase,letters uppercase}]
                        [--prefix PREFIX] [--firstpagenum FIRSTPAGENUM]
                        [--outfile out.pdf]

Add page labels to a PDF file

positional arguments:
  file.pdf              the PDF file to edit

optional arguments:
  -h, --help            show this help message and exit
  --delete              delete the existing page labels
  --startpage STARTPAGE, -s STARTPAGE
                        the index (starting from 1) of the page of the PDF
                        where the labels will start
  --type {arabic,roman lowercase,roman uppercase,letters lowercase,letters uppercase}, -t {arabic,roman lowercase,roman uppercase,letters lowercase,letters uppercase}
                        type of numbers: arabic = 1, 2, 3, roman = i, ii, iii,
                        iv, letters = a, b, c
  --prefix PREFIX, -p PREFIX
                        prefix to the page labels
                        number to attribute to the first page of this index
  --outfile out.pdf, -o out.pdf
                        Where to write the output file

Delete existing page labels from a PDF

$ ./ --delete

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pagelabels, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size pagelabels-1.0.0.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View
Filename, size pagelabels-1.0.0-py3-none-any.whl (16.7 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page