-
Notifications
You must be signed in to change notification settings - Fork 647
Closed
Labels
Description
Description of the bug
When setting the border of links I get the following error:
max@merry ~/github/zotlinksToPdfs [14:05:18]
(base) > $ python demo.py
Traceback (most recent call last):
File "/home/max/github/zotlinksToPdfs/demo.py", line 12, in <module>
link.set_border({'width': 1.0, 'dashes': [], 'style': "S"})
File "/home/max/miniconda3/lib/python3.11/site-packages/pymupdf/__init__.py", line 6475, in set_border
return self._setBorder(border, self.parent.parent.this, self.xref)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/max/miniconda3/lib/python3.11/site-packages/pymupdf/__init__.py", line 6383, in _setBorder
b = JM_annot_set_border(border, pdf, link_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/max/miniconda3/lib/python3.11/site-packages/pymupdf/__init__.py", line 14385, in JM_annot_set_border
if nclouds < 0:
^^^^^^^^^^^
TypeError: '<' not supported between instances of 'NoneType' and 'int'
How to reproduce the bug
The minimal example to reproduce the bug is
import fitz # PyMuPDF
print(fitz.__version__)
doc = fitz.open("test.pdf")
for page_num in range(len(doc)):
page = doc.load_page(page_num)
link = page.load_links()
while link is not None:
link.set_border({'width': 1.0, 'dashes': [], 'style': "S"})
link = link.next
doc.close()
Thanks for your efforts and the great tool.
Max
As a workaround I added a check for nclouds is not None and
in my local version, but I am not sure if this makes sense in general.
PyMuPDF version
1.24.9
Operating system
Linux
Python version
3.11