Skip to content

ENH: Add interface to annotations and AnnotationBuilder#1120

Merged
MartinThoma merged 13 commits into
mainfrom
annotations-raw-interface
Jul 22, 2022
Merged

ENH: Add interface to annotations and AnnotationBuilder#1120
MartinThoma merged 13 commits into
mainfrom
annotations-raw-interface

Conversation

@MartinThoma

@MartinThoma MartinThoma commented Jul 16, 2022

Copy link
Copy Markdown
Member
  • 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 force-pushed the annotations-raw-interface branch from 20953e0 to b4f9e05 Compare July 16, 2022 20:14
@MartinThoma
MartinThoma marked this pull request as ready for review July 20, 2022 19:41
@codecov

codecov Bot commented Jul 20, 2022

Copy link
Copy Markdown

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
MartinThoma requested a review from MasterOdin July 20, 2022 19:54
@MartinThoma

Copy link
Copy Markdown
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
Copy Markdown
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.

2 participants