本文主要是介绍[python3] pypdf2 处理书签,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
pypdf4 能添加书签,但是没有跳转功能 (PyPDF2好像还不能读取书签数据)
https://pythonhosted.org/PyPDF2/index.html
#!/mingw64/bin/python3
# -*- coding: utf-8 -*-from PyPDF2 import PdfFileWriter, PdfFileReader, PdfFileMerger, generic
import PyPDF2class GetPdfBookmark:deep_count = 0input = Nonebm = Noneinputname = Nonereallypagenum = {}tabs = ""def __init__(self, inputname):self.inputname = inputnametry:self.input = PdfFileReader(open(inputname, "rb"))except:quit()self.bm = self.input.outlinesself.__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)
这篇关于[python3] pypdf2 处理书签的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!