-
Notifications
You must be signed in to change notification settings - Fork 510
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
add_highlight_annot using clip generates "A Number is Out of Range" error in PDF #2322
Comments
This is not a bug, but incorrect use of the method - actually amazing that something was highlighted at all: The |
As an aside: Because of |
I do not understand what the proper use of the method should be. As you say, If you set quads to None then start and stop must not be None, so I tried these... but got the same issue.
In your follow up, you said I simply should have used my rectangle as the highlight rectangle. Do you mean to say I should use the method this way, where I set quads equal to rect? I agree this will avoid the error, but doesn't accomplish the same goal of "to highlight consecutive lines between the points start and stop" and rather just throws one highlight across all rows.
I would like to understand how to duplicate the example shown in the second note within the documentation |
This is correct: If using quads, all remaining parameters must be Both ways are mutually exclusive. Currently however, the method internally may generate infinite rectangles / quads which are the reason for the PDF viewer's complaint. This is fixed in the next release. |
Describe the bug (mandatory)
I am trying use page.add_highlight_annot with the clip option, and while the highlighting is placed as expected, the resulting PDF contains "A Number is Out of Range" error. The clip is built from information within the results of page.get_text("words", textpage=textpage) so I am not sure how my clip could be illegal. If this is not a bug, what I am doing wrong?
To Reproduce (mandatory)
test.pdf
Import Fitz and read PDF
Get Text and Do Text Stuff with it (here we find the index of target)
Get context around this target using the list index
Build a clip for this context text
Use the clip to add a highlight annotation
Save PDF
Expected behavior (optional)
I would expect not to get the "A Number is Out of Range" error
Screenshots (optional)
At first the highlighting doesn't show, only the error. But once you click 'Ok' the error goes away and highlighting shows. Any scrolling brings the error prompt back up.
After clicking 'Ok' and followed by and scrolling
Your configuration (mandatory)
Additional context (optional)
As always, thank you for the support!
The text was updated successfully, but these errors were encountered: