The addBookmark method returns a link to the created bookmark, which can be used as the parent for another bookmark. eg.
#!/usr/bin/env python from PyPDF2 import PdfFileWriter, PdfFileReader output = PdfFileWriter() input1 = PdfFileReader(open('introduction.pdf', 'rb')) output.addPage(input1.getPage(0)) input2 = PdfFileReader(open('hello.pdf', 'rb')) output.addPage(input2.getPage(0)) parent = output.addBookmark('Introduction', 0)
Snorfalorpagus
source share