-
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: automatic access to pointed object #2464
Conversation
alternative solution to py-pdf#2460 fixes py-pdf#2287
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2464 +/- ##
=======================================
Coverage 94.43% 94.44%
=======================================
Files 49 49
Lines 8013 8024 +11
Branches 1618 1618
=======================================
+ Hits 7567 7578 +11
Misses 276 276
Partials 170 170 ☔ View full report in Codecov by Sentry. |
Am I correct that the reason
If so, this feels wrong; in this scenario, should we not be using the |
the general objective of this PR is to flow down the call of the functions to pointed object. the "fix" about str is generic and will fix also possible issues with conversion to NumberObject or FloatObject /Your idea of pointing the existing Object is possible but will only covers MediaBox case |
Does this really involve doing some intermediate string step with this PR? |
Unless I'm misreading or misunderstanding, yeah. The pypdf/pypdf/generic/_rectangle.py Lines 20 to 26 in 88b8cb1
As the pypdf/pypdf/generic/_rectangle.py Lines 28 to 31 in 88b8cb1
The constructor of Lines 363 to 375 in 88b8cb1
|
I understand that this tends to solve more of the general IndirectObject issues we tend to encounter from time to time. Apparently, creating FloatObjects already involved the string conversion beforehand, thus this should not change much. Some things which I would like to consider/clarify before merging:
|
The only way I can image would be a IndirectObject referencing an IndirectObject which should not exist
This should fix some other issue.
yes it should allow to remove many .get_object() some open issues should be solved too |
there is an issue in the test but this seems not linked to the PR. any ideas ? |
The file from #1896 does not exist any more: https://www.selbst.de/paidcontent/dl/64733/72916 Do you see an easy way to replace it? Alternatively we probably have to remove this test for now. In both cases, we most likely should do this in a separate PR to keep things clean. |
This only fails on Windows as we do not use the cache there. If we want to continue using the same test file, https://github.com/stefan6419846/pypdf/actions/runs/8031448259/artifacts/1272068136 provides the file (zipped) as retrieved from the cache (will expire, thus we would have to upload this separately). |
Ok I see, the missing file : |
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.
Thanks @pubpub-zz for your work and @SamStephens for helping with the review. As #2460 tends to cover only one case, I am going to merge #2464 for now.
## What's new Generating name objects (`NameObject`) without a leading slash is considered deprecated now. Previously, just a plain warning would be logged, leading to possibly invalid PDF files. According to our deprecation policy, this will log a *DeprecationWarning* for now. ### New Features (ENH) - Add get_pages_from_field (#2494) by @pubpub-zz - Add reattach_fields function (#2480) by @pubpub-zz - Automatic access to pointed object for IndirectObject (#2464) by @pubpub-zz ### Bug Fixes (BUG) - Missing error on name without leading / (#2387) by @Rak424 - encode_pdfdocencoding() always returns bytes (#2440) by @sbourlon - BI in text content identified as image tag (#2459) by @pubpub-zz ### Robustness (ROB) - Missing basefont entry in type 3 font (#2469) by @pubpub-zz ### Documentation (DOC) - Improve lossless compression example (#2488) by @j-t-1 - Amend robustness documentation (#2479) by @j-t-1 ### Developer Experience (DEV) - Fix changelog for UTF-8 characters (#2462) by @stefan6419846 ### Maintenance (MAINT) - Add _get_page_number_from_indirect in writer (#2493) by @pubpub-zz - Remove user assignment for feature requests (#2483) by @stefan6419846 - Remove reference to old 2.0.0 branch (#2482) by @stefan6419846 ### Testing (TST) - Fix benchmark failures (#2481) by @stefan6419846 - Broken test due to expired test file URL (#2468) by @pubpub-zz - Resolve file naming conflict in test_iss1767 (#2445) by @sbourlon [Full Changelog](4.0.2...4.1.0)
## What's new Generating name objects (`NameObject`) without a leading slash is considered deprecated now. Previously, just a plain warning would be logged, leading to possibly invalid PDF files. According to our deprecation policy, this will log a *DeprecationWarning* for now. ### New Features (ENH) - Add get_pages_from_field (#2494) by @pubpub-zz - Add reattach_fields function (#2480) by @pubpub-zz - Automatic access to pointed object for IndirectObject (#2464) by @pubpub-zz ### Bug Fixes (BUG) - Missing error on name without leading / (#2387) by @Rak424 - encode_pdfdocencoding() always returns bytes (#2440) by @sbourlon - BI in text content identified as image tag (#2459) by @pubpub-zz ### Robustness (ROB) - Missing basefont entry in type 3 font (#2469) by @pubpub-zz ### Documentation (DOC) - Improve lossless compression example (#2488) by @j-t-1 - Amend robustness documentation (#2479) by @j-t-1 ### Developer Experience (DEV) - Fix changelog for UTF-8 characters (#2462) by @stefan6419846 ### Maintenance (MAINT) - Add _get_page_number_from_indirect in writer (#2493) by @pubpub-zz - Remove user assignment for feature requests (#2483) by @stefan6419846 - Remove reference to old 2.0.0 branch (#2482) by @stefan6419846 ### Testing (TST) - Fix benchmark failures (#2481) by @stefan6419846 - Broken test due to expired test file URL (#2468) by @pubpub-zz - Resolve file naming conflict in test_iss1767 (#2445) by @sbourlon [Full Changelog](4.0.2...4.1.0)
alternative solution to #2460
fixes #2287