-
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: Add AnnotationBuilder.widget(...) #1207
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Looking at some examples: >>> from PyPDF2 import PdfReader
>>> reader = PdfReader("pdf/04b33e0ac3e1dbfa2c575280319abf27.pdf")
>>> reader.pages[0].annotations
[IndirectObject(23, 0, 140234144846704), IndirectObject(25, 0, 140234144846704), IndirectObject(27, 0, 140234144846704), IndirectObject(29, 0, 140234144846704), IndirectObject(31, 0, 140234144846704), IndirectObject(33, 0, 140234144846704), IndirectObject(35, 0, 140234144846704), IndirectObject(37, 0, 140234144846704), IndirectObject(39, 0, 140234144846704), IndirectObject(41, 0, 140234144846704), IndirectObject(43, 0, 140234144846704), IndirectObject(45, 0, 140234144846704), IndirectObject(47, 0, 140234144846704), IndirectObject(49, 0, 140234144846704), IndirectObject(51, 0, 140234144846704), IndirectObject(53, 0, 140234144846704), IndirectObject(55, 0, 140234144846704), IndirectObject(57, 0, 140234144846704), IndirectObject(59, 0, 140234144846704), IndirectObject(61, 0, 140234144846704), IndirectObject(63, 0, 140234144846704), IndirectObject(65, 0, 140234144846704), IndirectObject(67, 0, 140234144846704), IndirectObject(69, 0, 140234144846704)]
>>> reader.pages[0].annotations[0]
IndirectObject(23, 0, 140234144846704)
>>> reader.pages[0].annotations[0].get_object()
{'/Rect': [191.775, 642.631, 504.437, 652.758], '/Subtype': '/Widget', '/BS': {'/S': '/S', '/W': 2}, '/Parent': IndirectObject(8, 0, 140234144846704), '/P': IndirectObject(21, 0, 140234144846704), '/Type': '/Annot', '/MK': {'/BG': [1, 1, 0]}, '/AP': {'/N': IndirectObject(24, 0, 140234144846704)}}
>>> reader.pages[0].annotations[0].get_object()['/Parent']
{'/T': 'Back', '/DA': '/Times 8 Tf 0 g', '/FT': '/Tx', '/Ff': 1, '/Kids': [IndirectObject(23, 0, 140234144846704), IndirectObject(25, 0, 140234144846704), IndirectObject(27, 0, 140234144846704), IndirectObject(29, 0, 140234144846704), IndirectObject(31, 0, 140234144846704), IndirectObject(33, 0, 140234144846704), IndirectObject(35, 0, 140234144846704), IndirectObject(37, 0, 140234144846704), IndirectObject(39, 0, 140234144846704), IndirectObject(41, 0, 140234144846704), IndirectObject(43, 0, 140234144846704), IndirectObject(45, 0, 140234144846704)]}
>>> reader.pages[0].annotations[1].get_object()
{'/Rect': [191.775, 630.606, 504.437, 640.732], '/Subtype': '/Widget', '/BS': {'/S': '/S', '/W': 2}, '/Parent': IndirectObject(8, 0, 140234144846704), '/P': IndirectObject(21, 0, 140234144846704), '/Type': '/Annot', '/MK': {'/BG': [1, 1, 0]}, '/AP': {'/N': IndirectObject(26, 0, 140234144846704)}}
>>> reader.pages[0].annotations[2].get_object()
{'/Rect': [91.1404, 607.82, 503.804, 617.947], '/Subtype': '/Widget', '/BS': {'/S': '/S', '/W': 2}, '/Parent': IndirectObject(8, 0, 140234144846704), '/P': IndirectObject(21, 0, 140234144846704), '/Type': '/Annot', '/MK': {'/BG': [1, 1, 0]}, '/AP': {'/N': IndirectObject(28, 0, 140234144846704)}}
>>> reader.pages[0].annotations[3].get_object()
{'/Rect': [192.407, 593.896, 505.07, 604.023], '/Subtype': '/Widget', '/BS': {'/S': '/S', '/W': 2}, '/Parent': IndirectObject(8, 0, 140234144846704), '/P': IndirectObject(21, 0, 140234144846704), '/Type': '/Annot', '/MK': {'/BG': [1, 1, 0]}, '/AP': {'/N': IndirectObject(30, 0, 140234144846704)}} Beautifying the first: {
"/Type": "/Annot",
"/Subtype": "/Widget",
"/Rect": [
191.775,
642.631,
504.437,
652.758
],
"/BS": {
"/S": "/S",
"/W": 2
},
"/Parent": "IndirectObject(...)",
"/P": "IndirectObject(...)",
"/MK": {
"/BG": [
1,
1,
0
]
},
"/AP": {
"/N": "IndirectObject(...)"
}
} And looking at its indirect objects:
|
MartinThoma
force-pushed
the
widget-annotation
branch
from
August 5, 2022 19:54
dba6075
to
9ae4f9a
Compare
* build_appearence_characteristics
MartinThoma
force-pushed
the
widget-annotation
branch
from
August 6, 2022 05:54
9ae4f9a
to
4e9d300
Compare
Codecov Report
@@ Coverage Diff @@
## main #1207 +/- ##
==========================================
- Coverage 92.15% 92.12% -0.04%
==========================================
Files 24 24
Lines 4948 4962 +14
Branches 1024 1029 +5
==========================================
+ Hits 4560 4571 +11
Misses 244 244
- Partials 144 147 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
MartinThoma
added
the
help wanted
We appreciate help everywhere - this one might be an easy start!
label
Aug 27, 2022
I'm closing this PR as I couldn't make it work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #107