-
Notifications
You must be signed in to change notification settings - Fork 17
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
Unexpected behavior: get_rect() requires count_rects() #207
Comments
Thanks for reporting this! PDFium docs say
so presumably this is a known (deliberate) requirement of pdfium that Apart from that, |
Yeah, I agree (and must say it's a weird design choice...) |
Hmm, yeah, I guess GetRect() needs to know rect count for an OOB check of the caller's index (as this is C), but then one would think GetRect() could call CountRects() internally if no value was assigned to the cache yet. |
Exactly! |
Do you think a proper exception for get_rect() with hint to check if count_rects() was called would be sufficient? I could also implement the implicit count_rects() call, but that would involve a state variable and an additional if check for all get_rect() calls on our side, just to handle this edge case. Hardly seems worth it TBH. |
OK, that makes sense. An exception along with a note in get_rect()'s documentation will probably suffice :) |
Just saw your commit. Looks great, thanks! |
In fact this issue reveals a bigger problem than initially thought. |
Oh :/ yeah that makes it sounds like a mistake rather than just weird |
anyway, thanks a lot for reporting this |
Hi,
It seems
get_rect()
returns the actual rectangle only ifcount_rects()
was previously executed on the same PdfTextPage object.Here's a code example to reproduce:
Output:
The text was updated successfully, but these errors were encountered: