-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ENH: Add page_number property #1856
Conversation
add a new property to ease access to page number on all objects
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1856 +/- ##
==========================================
+ Coverage 93.53% 93.56% +0.02%
==========================================
Files 34 34
Lines 6625 6634 +9
Branches 1296 1297 +1
==========================================
+ Hits 6197 6207 +10
Misses 281 281
+ Partials 147 146 -1
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the "not attached" case is something I would like to do different. The rest looks good :-)
_get_page_number_by_indirect returns -1 if the page is not found(includes not attached). we will have to change it also? |
Oh, interesting. So we have that behavior for a long time in the code base. I don't care too much about the internal/private functions. I'm torn now: One the one hand, I think "-1" might cause issues that "None" or an exception would not cause. Let me think about it until Sunday 🤔 |
(I tend to say "leave things as you already did" though - if we have want to change that, we can do it in one go for the whole codebase) |
New Features (ENH): - Add page_number property (#1856) Bug Fixes (BUG): - File expansion when updating with Page Contents (#1906) - Missing Alternate in indexed/ICCbased colorspaces (#1896) [Full Changelog](3.10.0...3.11.0)
I'd encourage you to switch from -1 to None for the "no page number available" case, as reverse indexing accidents are just too likely. In my experience, many callers aren't careful about correct error handling, and None is safer in any case. |
I've opened #1914 so that I don't forget about it. I want to keep pypdf stable for this year, but we had already a couple of breaking changes. I will collect them and do them all in one go. |
add a new property to ease access to page number on all objects
is used in further fix