我正在尝试使用 package.json 将目录添加到 pdf 中fitz
。
这是我的脚本
doc = fitz.open(path)
bookmarks = [[1, 'INTRODUCTION', 1], [1, 'MANUSCRIPT COMPONENTS', 1], [1, 'MULTIMEDIA FIGURES – VIDEO AND AUDIO FILES', 2], [1, 'MATHEMATICAL EQUATIONS', 3], [1, 'USING THIS TEMPLATE AND ITS AUTOMATIC FORMATTING', 3]]
doc.setToC(bookmarks) # o/p -> 5
doc.save(doc.name, incremental=True) # to save the document with added bookmarks/table of contents
# above line gives the error
这是堆栈跟踪
>>> doc.save(doc.name, incremental=True)
mupdf: Can't do incremental writes when changing encryption
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\BookmarkPDF\pdfenv\lib\site-packages\fitz\fitz.py", line 4270, in save
return _fitz.Document_save(
RuntimeError: Can't do incremental writes when changing encryption