Add bookmarks into PDF using PyPDF2.
Install pdfbookmarker:
$ pip install pdfbookmarker-
Turn to your target PDF (e.g.
MyBook.pdf), record bookmark titles and page numbers of the PDF into a TEXT file (e.g.my_bookmarks.txt) by hand with the following format:<nested level>"<bookmark title>"|<page number>For samples, see sample_bookmarks.txt. (Offsets are also supported, see here)
-
Generate a copy of
MyBook.pdfwith additional bookmarks file specified bymy_bookmarks.txt:$ pdfbm MyBook.pdf my_bookmarks.txt
An auto-detected, expected or suggested filename for bookmarks is
MyBook.txt, when the input filenamne e.g. isMyBook.pdf.The default filename of the output PDF is
MyBook-new.pdf; You, of course, can specify the filename explicitly:$ pdfbm MyBook.pdf my_bookmarks.txt MyBook_with_bookmarks.pdf