AttributeError when using doc.setToC (original) (raw)

Describe the bug

doc.setToC causes Attribute Error in the latest version of PyMuPDF. The detailed error message is as follows

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-ab676f284c83> in <module>
----> 1 doc.setToC(toc)

/usr/lib/python3.9/site-packages/fitz/utils.py in setToC(doc, toc, collapse)
   1105             txt += "/Type/Outlines"  # so add the /Type entry
   1106         txt += ">>"
-> 1107         doc._updateObject(xref[i], txt)  # insert the PDF object
   1108
   1109     doc.initData()

AttributeError: 'Document' object has no attribute '_updateObject'

To Reproduce

First, prepare any PDF file with a table of contents and name it doc.pdf.

import fitz doc = fitz.open("doc.pdf") toc = doc.getToC() doc.setToC(toc)


AttributeError Traceback (most recent call last) in ----> 1 doc.setToC(toc)

/usr/lib/python3.9/site-packages/fitz/utils.py in setToC(doc, toc, collapse) 1105 txt += "/Type/Outlines" # so add the /Type entry 1106 txt += ">>" -> 1107 doc._updateObject(xref[i], txt) # insert the PDF object 1108 1109 doc.initData()

AttributeError: 'Document' object has no attribute '_updateObject'

Expected behavior

No error occurs.

Your configuration (mandatory)

3.9.1 (default, Dec 13 2020, 11:55:53)
[GCC 10.2.0]
 linux

PyMuPDF 1.18.5: Python bindings for the MuPDF 1.18.0 library.
Version date: 2020-12-15 01:53:11.
Built for Python 3.9 on linux (64-bit).

PyMuPDF is installed using wheel.