Skip to main content

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 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")

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.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

pagelabels-1.1.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file pagelabels-1.1.0.tar.gz.

File metadata

  • Download URL: pagelabels-1.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.4

File hashes

Hashes for pagelabels-1.1.0.tar.gz
Algorithm Hash digest
SHA256 88ba2ebc6a783a0310eb0628baaafde4826c8a855568560190652551af6356b6
MD5 baf27cf38107d742067ffc002ac4f1f3
BLAKE2b-256 0bd5e8ea1e33b6ba9ac5cc530a964cef692124994ced872eb3264dbb22c70fd2

See more details on using hashes here.

File details

Details for the file pagelabels-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pagelabels-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.4

File hashes

Hashes for pagelabels-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd071683477681c6953f21cd05685a061ff99a44f84858f5d564bc41b590b00d
MD5 7db1c2b8ca1471f28cf4ce195e008805
BLAKE2b-256 fa8c79480331bb304b4a7ea3ca1df9172487afcb07eb455351d5b57eec489baf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page