PyMuPDF
PyMuPDF copied to clipboard
page.get_pixmap() fails due to `fitz.mupdf.FzErrorLimit: code=5: too many nested graphics states`
Description of the bug
Trying to get the pixmap of certain pdf documents fails:
File "/home/.../test.py", line 11, in <module>
_ = page.get_pixmap()
^^^^^^^^^^^^^^^^^
File "/home/.../miniconda3/lib/python3.12/site-packages/fitz/utils.py", line 888, in get_pixmap
dl = page.get_displaylist(annots=annots)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/.../miniconda3/lib/python3.12/site-packages/fitz/__init__.py", line 8768, in get_displaylist
dl = mupdf.fz_new_display_list_from_page(self.this)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/.../miniconda3/lib/python3.12/site-packages/fitz/mupdf.py", line 42912, in fz_new_display_list_from_page
return _mupdf.fz_new_display_list_from_page(page)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
fitz.mupdf.FzErrorLimit: code=5: too many nested graphics states
How to reproduce the bug
with fitz.open(pdf_file) as doc:
page, *_ = doc.pages()
_ = page.get_pixmap()
with latest pymupdf version. The same constellation runs just fine with at least pymupdf==1.22.5 . Unfortunately, I cannot provide affected files, but it seems to hit some hardcoded recursion limit - maybe a parameter to configure this limit would be enough?
PyMuPDF version
1.24.5
Operating system
Linux
Python version
3.12