You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just as a heads-up in case someone else encounters this issue.
While parsing several hundred files, I got this error-message for many of these files: ValueError: Data must be padded to 16 byte boundary in CBC mode
This is an issue in the upstream PyPDF2-package at least in version 2.11.1.
There's a bug-report in the PyPDF2-repo and a 3-line quickfix has already been commited. I've modified PyPDF2/_encryption.py in my local site-package accordingly and no longer see the error. I assume the patch will soon be published in a package as well.
My PyPDF2-version is 2.11.1
Here's the full traceback for reference.
Traceback (most recent call last):
File "/home/benke/workspace/solarkeymark_importer/parse_certificate.py", line 91, in <module>
tables = camelot.read_pdf(f"{pdf_dir}{file}", pages='1-end', line_scale=110, shift_text=[''])
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/camelot/io.py", line 113, in read_pdf
tables = p.parse(
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/camelot/handlers.py", line 169, in parse
self._save_page(self.filepath, p, tempdir)
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/camelot/handlers.py", line 117, in _save_page
outfile.write(f)
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/PyPDF2/_writer.py", line 841, in write
self.write_stream(stream)
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/PyPDF2/_writer.py", line 814, in write_stream
self._sweep_indirect_references(self._root)
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/PyPDF2/_writer.py", line 963, in _sweep_indirect_references
data = self._resolve_indirect_object(data)
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/PyPDF2/_writer.py", line 1008, in _resolve_indirect_object
real_obj = data.pdf.get_object(data)
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/PyPDF2/_reader.py", line 1231, in get_object
retval = self._encryption.decrypt_object(
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/PyPDF2/_encryption.py", line 750, in decrypt_object
return cf.decrypt_object(obj)
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/PyPDF2/_encryption.py", line 188, in decrypt_object
obj[dictkey] = self.decrypt_object(value)
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/PyPDF2/_encryption.py", line 182, in decrypt_object
data = self.strCrypt.decrypt(obj.original_bytes)
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/PyPDF2/_encryption.py", line 90, in decrypt
d = aes.decrypt(data)
File "/home/benke/workspace/solarkeymark_importer/lib/python3.10/site-packages/Crypto/Cipher/_mode_cbc.py", line 246, in decrypt
raise ValueError("Data must be padded to %d byte boundary in CBC mode" % self.block_size)
ValueError: Data must be padded to 16 byte boundary in CBC mode
The text was updated successfully, but these errors were encountered:
Just as a heads-up in case someone else encounters this issue.
While parsing several hundred files, I got this error-message for many of these files:
ValueError: Data must be padded to 16 byte boundary in CBC mode
This is an issue in the upstream PyPDF2-package at least in version
2.11.1
.There's a bug-report in the
PyPDF2
-repo and a 3-line quickfix has already been commited. I've modifiedPyPDF2/_encryption.py
in my local site-package accordingly and no longer see the error. I assume the patch will soon be published in a package as well.My
PyPDF2
-version is2.11.1
Here's the full traceback for reference.
The text was updated successfully, but these errors were encountered: