-
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: Enable merging forms with overlapping names #1553
Conversation
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>
Codecov ReportBase: 91.84% // Head: 91.89% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1553 +/- ##
==========================================
+ Coverage 91.84% 91.89% +0.04%
==========================================
Files 33 33
Lines 6196 6244 +48
Branches 1229 1242 +13
==========================================
+ Hits 5691 5738 +47
Misses 326 326
- Partials 179 180 +1
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. |
Test to be improved 😉 |
Looks good from my side. If you think it's ready, I could merge it :-) |
Will try first to improve slightly the test tonight to prevent coverage degradation |
Co-authored-by: Martin Thoma <info@martin-thoma.de>
@MartinThoma |
if "/AcroForm" not in catalog or not isinstance( | ||
catalog["/AcroForm"], DictionaryObject | ||
): | ||
return None |
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.
What do you think about raising a MissingElementException("/AcroForm not in catalog")
instead of returning None
?
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.
This cover the case where the form is not a form. I considered that the function should not raise an error
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.
What is a form that is not a form? Did you want to write "AcroForm"?
Does that mean that this grouping only makes sense for AcroForm? (I don't understand the AcroForm parts yet)
@MartinThoma, can you provide upgrade on my comments. Should I mark them as resolved ? |
@pubpub-zz I've added a comment:
What do you mean by "the form is not a form"? |
I mixed up : I meant the doc passed is not actually a form. when docs are passed in batchs for example. For the |
So you don't want to add an Exception because the exception could be wrong for XFA. Did I understand that right? Could you add this as a comment in the code? It might make my life easier in future when somebody edits that part :-) |
Co-authored-by: Martin Thoma <info@martin-thoma.de>
Co-authored-by: Martin Thoma <info@martin-thoma.de>
Looks good to me! If you wan't I can merge today :-) |
@pubpub-zz I took the "thumbs up" as "go ahead and merge" :-) I'll make the release latest on Sunday; depends on my workload. |
NOTICE: pypdf changed the way it represents numbers parsed from PDF files. pypdf<3.4.0 represented numbers as Decimal, pypdf>=3.4.0 represents them as floats. Several other PDF libraries to this, as well as many PDF viewers. We hope to fix issues with too high precision like this and get a speed boost. In case your PDF documents rely on more than 18 decimals of precision you should check if it still works as expected. To clarify: This does not affect the text shown in PDF documents. It affects numbers, e.g. when graphics are drawn on the PDF or very exact positions are used. Typically, 5 decimals should be enough. New Features (ENH) - Enable merging forms with overlapping names (#1553) - Add 'over' parameter to merge_transformend_page & co (#1567) Bug Fixes (BUG) - Fix getter of the PageObject.rotation property with an indirect object (#1602) - Restore merge_transformed_page & co (#1567) - Replace decimal by float (#1563) Robustness (ROB) - PdfWriter.remove_images: /Contents might not be in page_ref (#1598) Developer Experience (DEV) - Introduce ruff (#1586, #1609) Maintenance (MAINT) - Remove decimal (#1608) [Full Changelog](3.3.0...3.4.0)
Add functions to add a top level grouping form field.
Functions to rename top level field also introduced.
PdfWriter.merge
/PdfWriter.append
extended to merge set of fields.Closes #1538
Closes #1585