-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
PdfFileReader load cleanup #343
Conversation
- Remove special read() method that was really never intended to be "public" and would simply mess things up if called more than once. - Load security handler lazily. This means that accessing an encrypted document with wrong credentials will now only fail upon trying to access the first encrypted object, as opposed to failing at init time.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #343 +/- ##
=======================================
Coverage 98.81% 98.82%
=======================================
Files 113 113
Lines 16259 16270 +11
=======================================
+ Hits 16067 16079 +12
+ Misses 192 191 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
LGTM -- I can confirm that encrypt_dict is now accessible as a class property 🎉 If you want, you could probably dump |
Yeah, fair enough. Yesterday me thought we might as well preserve the |
…-edit Add encrypt dict using property decorator
Description of the changes
Clean up some of the init logic in
PdfFileReader
(without fundamentally changing the fact that the xref table is processed during__init__
), and in particular, for encrypted files, we now defer loading of the security handler to a later point. As a side effect, this means that problems with the security handler will be raised during object access and/or calls to.encrypt()/.decrypt()
rather than during__init__
, which is hopefully a bit more user-friendly. It also exposes the encryption dictionary as a property on thePdfFileReader
class.Closes #332.
Caveats
Technically, the removal of the
.read()
method onPdfFileReader
is a breaking change. Practically, it's not, since calling that method out of order would already have broken all sorts of things anyway.Checklist
Please go over this checklist to increase the chances of your PR being worked on in a timely manner. Deviations are allowed with proper justification (see previous section).
For new features (delete if not applicable)