Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link.set_border gives TypeError: '<' not supported between instances of 'NoneType' and 'int' #3773

Closed
noppelmax opened this issue Aug 13, 2024 · 2 comments
Labels
bug fix developed release schedule to be determined

Comments

@noppelmax
Copy link

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

@JorjMcKie JorjMcKie added the bug label Aug 13, 2024
@JorjMcKie
Copy link
Collaborator

Thanks for the report.
Bug confirmed, fix will be trivial.

@JorjMcKie JorjMcKie added the fix developed release schedule to be determined label Aug 13, 2024
@julian-smith-artifex-com
Copy link
Collaborator

Fixed in 1.24.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix developed release schedule to be determined
Projects
None yet
Development

No branches or pull requests

3 participants