Skip to main content

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 PageLabelSchemes.

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 scheme
  • style : one of the strings arabic, roman uppercase, letters uppercase, roman lowercase, letters lowercase
  • prefix : string to prepend to all page labels
  • firstpagenum : 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")

Metadata

Release files for pagelabels 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pagelabels 1.2.1
File Size Uploaded Provenance Actions
pagelabels-1.2.1.tar.gz 18.4 kB Without provenance Details for pagelabels-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pagelabels 1.2.1
File Interpreter ABI Platform Actions
pagelabels-1.2.1-py3-none-any.whl Python 3 none any Details for pagelabels-1.2.1-py3-none-any.whl

Total release size: 36.1 kB

Release files / pagelabels-1.2.1.tar.gz

Download URL pagelabels-1.2.1.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
180132844093a0a9c8581c6761348eb18299063979d1bffcda667af22f08dae8
BLAKE2b-256 checksum
How to use checksums
ae45e6ee83581c78213e8ccd16a8324b97dfb4c420f0ffad9bddc348d233ad9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / pagelabels-1.2.1-py3-none-any.whl

Download URL pagelabels-1.2.1-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
522401e42c5cd4bec29e2a75a859015053b0691be60d9f97be4faa7ffb4970e4
BLAKE2b-256 checksum
How to use checksums
7f5e8d76c43f0a427aee4fb66de11c46529538cac72724058bd6428d18bbc316
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for pagelabels 1.2.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page