Conversation
|
I'm not sure why the CI is failing indicating that the annotations aren't iterable - it seems to be when I run it and I based the code on the docs here: https://pypdf2.readthedocs.io/en/latest/user/reading-pdf-annotations.html?highlight=annotations Perhaps it's not guaranteed to be iterable and there needs to be some form of type guard before attempting to iterate it. |
Codecov ReportBase: 93.97% // Head: 93.93% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1479 +/- ##
==========================================
- Coverage 93.97% 93.93% -0.05%
==========================================
Files 30 30
Lines 5446 5459 +13
Branches 1039 1044 +5
==========================================
+ Hits 5118 5128 +10
Misses 198 198
- Partials 130 133 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
@joshhendo Thank you for taking care of it 🙏 I'll release it to PyPI today :-) If you want, I can add you to the list of contributors: https://pypdf2.readthedocs.io/en/latest/meta/CONTRIBUTORS.html :-) |
New Features (ENH): - Add support to extract gray scale images (#1460) - Add 'threads' property to PdfWriter (#1458) - Add 'open_destination' property to PdfWriter (#1431) - Make PdfReader.get_object accept integer arguments (#1459) Bug Fixes (BUG): - Scale PDF annotations (#1479) Robustness (ROB): - Padding issue with AES encryption (#1469) - Accept empty object as null objects (#1477) Documentation (DOC): - Add module documentation the PaperSize class (#1447) Maintenance (MAINT): - Use 'page_number' instead of 'pagenum' (#1365) - Add List of pages to PageRangeSpec (#1456) Testing (TST): - Cleanup temporary files (#1454) - Mark test_tounicode_is_identity as external (#1449) - Use Ubuntu 20.04 for running CI test suite (#1452) [Full Changelog](2.11.2...2.12.0)
|
Thanks @MartinThoma ! And for fixing the mypy issue - I was on the right path thinking that narrowing/a type guard was needed. I have never used mypy before so I had been trying to get it working locally for me to work on. |
That would be great! |
|
@joshhendo / @MartinThoma @joshhendo, are you OK to upgrade your code change ? |

Fixes #1386
PDF annotations - for example hyperlinks and comments - aren't properly scaled when using the scale function.
I tried to follow a similar pattern to the code just below my change which scales the Viewport.
As a test, the input PDF is as follows:

In this screenshot, I am clicking on the link and Adobe Acrobat shows it as a black box. This is in the position I expect.
When scaled to 0.9 without this fix, the following occurs:

The clickable area for the link has changed, as well as the comment.
The PDF used to test was:
test_input.pdf
The PDF scaled to 0.9 before the fix:
test_output_before.pdf
The PDF scaled to 0.9 after the fix:
test_output_after.pdf