pypdf4 能添加书签,但是没有跳转功能 (PyPDF2好像还不能读取书签数据)
https://pythonhosted.org/PyPDF2/index.html
#!/mingw64/bin/python3
# -*- coding: utf-8 -*-
from PyPDF2 import PdfFileWriter, PdfFileReader, PdfFileMerger, generic
import PyPDF2
class GetPdfBookmark:
deep_count = 0
input = None
bm = None
inputname = None
reallypagenum = {
}
tabs = ""
def __init__(self, inputname):
self.inputname = inputname
try:
self.input = PdfFileReader(open(inputname, "rb"))
except:
quit()
self.bm = self.input.outlines
self.__FixBookmarksPageNumber(self.input.getPage(0)['/Parent']['/Kids'], self.input.getPage(0)['/Parent']['/Count'])
def __FixBookmarksPageNumber(self, data, data_len):
for i in range(data_len):
self.reallypagenum[str(data[i].idnum)] = str(i)