Skip to content
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

BUG: Use NumberObject for /Border elements of annotations #2451

Merged
merged 2 commits into from
Feb 13, 2024

Conversation

rsinger417
Copy link
Contributor

@rsinger417 rsinger417 commented Feb 8, 2024

As defined in Table 164 – Entries common to all annotation dictionaries, the /Border Array consists of NumberObjects. Previously, pypdf used NameObject which is wrong.

The previous version caused a warning in the class NameObject method renumber "Incorrect first char in NameObject:({self})" line 592 _base.py (pypdf.generic)

Fixes #2444

Change NameObject to NumberObject in lines 328 and 330 It will pass the array as a string and not an int if it is a NameObject and will cause a warning in the Class NameObject method renumber "Incorrect first char in NameObject:({self})" line 592 _base.py (pypdf.generic)
resolves py-pdf#2444 Issue
@stefan6419846
Copy link
Collaborator

You do not need to open a new PR and close the old PR for each modification you do.

Could you please add a corresponding test case as well which shows the previous issue and demonstrates that your fix does indeed solve this? Apparently you would get warnings previously (#2447 (comment)), which might be something to check.

@rsinger417
Copy link
Contributor Author

I'm sorry I have never done this before. I'm just learning by making a lot of mistakes. I deleted the branch after summiting the first PRs, which closed the PRs and lost the all of the code changes, so I made new PRs trying to fix the error. I made a pdf describing the bug in more detail with screen shots for you.
pydff PR #2447 more detail explanation of bug.pdf

@MartinThoma MartinThoma changed the title Update _markup_annotations.py #2447 BUG: Update _markup_annotations.py #2447 Feb 13, 2024
Copy link

codecov bot commented Feb 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3fb63f7) 94.43% compared to head (99e00a2) 94.43%.
Report is 1 commits behind head on main.

❗ Current head 99e00a2 differs from pull request most recent head b8f2ba3. Consider uploading reports for the commit b8f2ba3 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2451   +/-   ##
=======================================
  Coverage   94.43%   94.43%           
=======================================
  Files          49       49           
  Lines        8008     8008           
  Branches     1616     1616           
=======================================
  Hits         7562     7562           
  Misses        276      276           
  Partials      170      170           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MartinThoma MartinThoma changed the title BUG: Update _markup_annotations.py #2447 BUG: Use NumberObject for /Border elements of annotations Feb 13, 2024
@MartinThoma MartinThoma merged commit b7bfd0d into py-pdf:main Feb 13, 2024
12 checks passed
@MartinThoma
Copy link
Member

Congratulations to your first accepted contribution @rsinger417 ! Thank you for helping to improve pypdf 🙏

If you want, I can add you to https://pypdf.readthedocs.io/en/latest/meta/CONTRIBUTORS.html :-)

@MartinThoma
Copy link
Member

The fix will be released in pypdf > 4.01 (likely on Sunday, 18th of February)

@MartinThoma
Copy link
Member

I like that the PR was small - especially for first contributions this is a good idea 👍

A few details to watch out for the next time. Don't worry, in this PR I took care of it already:

  • PR title: This will be used for generating the CHANGELOG. Take one of the projects prefixes + add something short and descriptive.
  • PR description: I try to take exactly the first posts description as a commit message. It should briefly describe the issue. If possible, reference the relevant part in the PDF specs.
  • Tests: As stefan rightfully pointed out, having tests is always a good idea. In this specific case, having a section of the PDF specs was good enough to directly merge it.

MartinThoma added a commit that referenced this pull request Feb 18, 2024
## What's new

### Bug Fixes (BUG)
-  Use NumberObject for /Border elements of annotations (#2451) by @rsinger417

### Documentation (DOC)
-  Document easier way to update metadata (#2454) by @stefan6419846
-  Typo `Polyline` \xe2\x86\x92 `PolyLine` in adding-pdf-annotations.md (#2426) by @CWKSC

### Developer Experience (DEV)
-  Bump codecov/codecov-action from 3 to 4 (#2430) by @dependabot[bot]

### Testing (TST)
-  Avoid catching not emitted warnings (#2429) by @stefan6419846

[Full Changelog](4.0.1...4.0.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in Class Link when using border in arguments. example border = [0,0,1, [3,2]]
3 participants