I a trying to read a PDF document using Python with PyPDF2 package. The objective is to read all the bookmarks in the pdf and construct a dictionary with page numbers of the bookmark as keys and titles of bookmarks as values.
There is not much support on the internet on how to achieve it except for this article. The code posted in it doesn't work and i am not an expert in python to correct it. PyPDF2's reader object has a property named outlines which gives you a list of all bookmark objects but there are no page numbers for bookmarks and traversing the list is little difficult as there are no parent/child relationships between bookmarks.
I am sharing below my code to read a pdf document and inspect outlines property.
import PyPDF2
reader = PyPDF2.PdfFileReader('SomeDocument.pdf')
print(reader.numPages)
print(reader.outlines[1][1])