-
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 Cloning #1371
ENH: Add Cloning #1371
Conversation
add cloning capability includes: * add clone function * new API for add_page/insert_page that returns the cloned page object * close file when a file name is provided to PdfWriter.write
w.merge and w.append
to be iaw PDF Spec add page clean up for destination in NameObject that are not matching TextStringObject in Names/Dests
Codecov ReportBase: 94.14% // Head: 92.70% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1371 +/- ##
==========================================
- Coverage 94.14% 92.70% -1.44%
==========================================
Files 31 29 -2
Lines 5480 5691 +211
Branches 1037 1112 +75
==========================================
+ Hits 5159 5276 +117
- Misses 193 267 +74
- Partials 128 148 +20
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy didn't complain when I checked. As you asked me to look at mypy, I checked all 'type: ignore' comments. Several were not necessary at all. In some cases mypy needed an assert variable is not None
as a hint. And in some cases I could at least narrow the ignore down to be a bit more specific
Co-authored-by: Martin Thoma <info@martin-thoma.de>
Co-authored-by: Martin Thoma <info@martin-thoma.de>
Co-authored-by: Martin Thoma <info@martin-thoma.de>
Co-authored-by: Martin Thoma <info@martin-thoma.de>
Finally! I'll have another quick look at the code and then merge today :-) |
@pubpub-zz Thank you so much for this moonshot extension 🙏 ❤️ |
@pubpub-zz thanks for all the effort you've put into this PR! |
BREAKING CHANGES: - Deprecate features with PyPDF2==3.0.0 (#1489) - Refactor Fit / Zoom parameters (#1437) New Features (ENH): - Add Cloning (#1371) - Allow int for indirect_reference in PdfWriter.get_object (#1490) Documentation (DOC): - How to read PDFs from S3 (#1509) - Make MyST parse all links as simple hyperlinks (#1506) - Changed 'latest' for 'stable' generated docs (#1495) - Adjust deprecation procedure (#1487) Maintenance (MAINT): - Use typing.IO for file streams (#1498) [Full Changelog](2.12.1...3.0.0)
The method
.clone(pdf_dest,[force_duplicate])
clones the objects and all referenced objects.If an object is already cloned, the already cloned object is returned (unless force_duplicate is set)
mainly for internal use but can be used on a page
for pageObject/DictionnaryObject/[Encoded/Decoded/Content]Stream an extra parameter ignore_fields list that provide the list of fields that should not be cloned.
When available, the pointer to an object is available in
indirect_obj
attribute.New API for add_page/insert_page that :
Others
add_outline_item
now has a parameter before which is not the last parameterUpdate
Deals with #1194, #1322, #471, #1337