Python library to manipulate PDF page numbers and labels.
Project description
pagelabels python library
This is a little library, based on pdfrw, that helps manipulate PDF page labels in python. It can parse page labels from a PDF, edit page labels, and write them in a PDF.
For more info about page labels, see: https://www.w3.org/TR/WCAG20-TECHS/PDF17.html
Classes
PageLabels
Inherits from list and represents a list of PageLabelScheme
s.
PageLabels.from_pdf(pdfrwobj)
Static method. Read page labels from a PdfReader object.
.write(pdfrwobj)
Write the page labels to a PdfReader object.
PageLabelScheme
Inherits from a named tuple with fields:
startpage
: Index in the PDF where to start numbering pages according to this schemestyle
: one of the stringsarabic
,roman uppercase
,letters uppercase
,roman lowercase
,letters lowercase
prefix
: string to prepend to all page labelsfirstpagenum
: where to start the index
Example
from pdfrw import PdfReader, PdfWriter
from pagelabels import PageLabels, PageLabelScheme
reader = PdfReader("input.pdf")
labels = PageLabels.from_pdf(reader)
newlabel = PageLabelScheme(startpage=3, # the index of the page of the PDF where the labels will start
style="roman", # See options in PageLabelScheme.styles()
prefix="Appendix ",
firstpagenum=1) # number to attribute to the first page of this index
labels.append(newlabel) # Adding our page labels to the existing ones
labels.write(reader)
writer = PdfWriter()
writer.trailer = reader
writer.write("output.pdf")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pagelabels-1.2.1.tar.gz
(18.4 kB
view details)
Built Distribution
File details
Details for the file pagelabels-1.2.1.tar.gz
.
File metadata
- Download URL: pagelabels-1.2.1.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 180132844093a0a9c8581c6761348eb18299063979d1bffcda667af22f08dae8 |
|
MD5 | d856338491681b09c5f945d9fc193c50 |
|
BLAKE2b-256 | ae45e6ee83581c78213e8ccd16a8324b97dfb4c420f0ffad9bddc348d233ad9f |
File details
Details for the file pagelabels-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: pagelabels-1.2.1-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 522401e42c5cd4bec29e2a75a859015053b0691be60d9f97be4faa7ffb4970e4 |
|
MD5 | 87e628755aa31c73fa5536c06020b54e |
|
BLAKE2b-256 | 7f5e8d76c43f0a427aee4fb66de11c46529538cac72724058bd6428d18bbc316 |