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.0.2.tar.gz
(4.9 kB
view hashes)
Built Distribution
pagelabels-1.0.2-py3-none-any.whl
(16.5 kB
view hashes)
Close
Hashes for pagelabels-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90cea68983ec599f1fb511e025b46fd7e3224721c8100d1b9b1fd5ba2d791dcd |
|
MD5 | 349116c4d7a3ab002ec3904e4d0db01c |
|
BLAKE2b-256 | a06764cff4d9025d3cb789940e12873131be47e1279c3edc412aad55ed293243 |