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

ENH: Add interface to annotations and AnnotationBuilder #1120

Merged
merged 13 commits into from Jul 22, 2022

Conversation

MartinThoma
Copy link
Member

@MartinThoma MartinThoma commented Jul 16, 2022

  • Add page.annotations (getter and setter)
  • Add writer.add_annotation(page_number, annotation_dictionary)
  • Add AnnotationBuilder to generate the annotation_dictionary for the different subtypes of annotations. Similarly, we could have an AnnotationsParser.

See #107

Closes #981

@MartinThoma MartinThoma added the is-feature A feature request label Jul 16, 2022
@MartinThoma MartinThoma marked this pull request as ready for review July 20, 2022 19:41
@codecov
Copy link

codecov bot commented Jul 20, 2022

Codecov Report

Merging #1120 (848cc13) into main (6899c74) will increase coverage by 0.00%.
The diff coverage is 92.06%.

❗ Current head 848cc13 differs from pull request most recent head 4c49b7d. Consider uploading reports for the commit 4c49b7d to get more accurate results

@@           Coverage Diff           @@
##             main    #1120   +/-   ##
=======================================
  Coverage   91.96%   91.96%           
=======================================
  Files          24       24           
  Lines        4693     4756   +63     
  Branches      968      985   +17     
=======================================
+ Hits         4316     4374   +58     
- Misses        231      232    +1     
- Partials      146      150    +4     
Impacted Files Coverage Δ
PyPDF2/_page.py 92.35% <80.00%> (-0.26%) ⬇️
PyPDF2/generic.py 91.72% <91.30%> (-0.02%) ⬇️
PyPDF2/_writer.py 89.14% <96.66%> (+0.42%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 91357f0...4c49b7d. Read the comment docs.

@MartinThoma
Copy link
Member Author

@MasterOdin @pubpub-zz I'd be interested in your opinion. What to you think about adding this as an interface for annotations to PyPDF2?

@MartinThoma MartinThoma changed the title ENH: Add raw interface to annotations ENH: Add interface to annotations and AnnotationBuilder Jul 21, 2022
@pubpub-zz
Copy link
Collaborator

I completely agree with the approach. Part of my original interest in PyPDF4, was to work on merging comments from different users/source (you may be interested in https://github.com/pubpub-zz/PyPPDF4.sav/tree/master/samplecode )
More capabilities do exists within the annotation (drawings...) more work to come 😀

@MartinThoma MartinThoma merged commit 1a65a46 into main Jul 22, 2022
@MartinThoma MartinThoma deleted the annotations-raw-interface branch July 22, 2022 16:34
MartinThoma added a commit that referenced this pull request Jul 24, 2022
New Features (ENH):
-  Add writer.add_annotation, page.annotations, and generic.AnnotationBuilder (#1120)

Bug Fixes (BUG):
-  Set /AS for /Btn form fields in writer (#1161)
-  Ignore if /Perms verify failed (#1157)

Robustness (ROB):
-  Cope with utf16 character for space calculation (#1155)
-  Cope with null params for FitH / FitV destination (#1152)
-  Handle outlines without valid destination (#1076)

Developer Experience (DEV):
-  Introduce _utils.logger_warning (#1148)

Maintenance (MAINT):
-  Break up parse_to_unicode (#1162)
-  Add diagnostic output to exception in read_from_stream (#1159)
-  Reduce PdfReader.read complexity (#1151)

Testing (TST):
-  Add workflow tests found by arc testing (#1154)
-  Decrypt file which is not encrypted (#1149)
-  Test CryptRC4 encryption class; test image extraction filters (#1147)

Full Changelog: 2.7.0...2.8.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is-feature A feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants