Python 3.10.6 and Camelot crashes trying to read a table in a PDF file

Viewed 53

Using Python 3.10.6, I'm trying to read the tables in this PDF file, specifically on pages 24 and 26. I can read the tables on pages 21-23 and 25.

The only "commonality" I can find between those tables is: the unreadable tables' 2nd row is a single column, but the readable tables' 2nd row has multiple columns.

Here's the command I'm using:

tables = camelot.read_pdf( cFile
                         , pages=str(24)
                         , password=None
                         , flavor='lattice'
                         , flag_size=True
                         , strip_text='\n'
                         # , backend='poppler'
                         # , process_background=True
                         # , table_areas=['36,731,576,396']
                         # , table_regions=['36,731,576,396']
                         # , edge_tol=200
                         # , row_tol=10
                         # , line_scale=40
                         # , shift_text=['r', 'b']
                         # , copy_text=['h']
                         )

I've tried all those various arguments with no success.

Here's the error I'm getting:

Traceback (most recent call last):
  File "G:\My Drive\Bugs\15888 - Convert PDF table data to Oracle data\Test Table 9.py", line 58, in <module>
    tables = camelot.read_pdf( cFile
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\camelot\io.py", line 113, in read_pdf
    tables = p.parse(
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\camelot\handlers.py", line 172, in parse
    self._save_page(self.filepath, p, tempdir)
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\camelot\handlers.py", line 120, in _save_page
    outfile.write(f)
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\PyPDF2\_writer.py", line 839, in write
    self.write_stream(stream)
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\PyPDF2\_writer.py", line 812, in write_stream
    self._sweep_indirect_references(self._root)
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\PyPDF2\_writer.py", line 961, in _sweep_indirect_references
    data = self._resolve_indirect_object(data)
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\PyPDF2\_writer.py", line 1006, in _resolve_indirect_object
    real_obj = data.pdf.get_object(data)
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\PyPDF2\_reader.py", line 1160, in get_object
    retval = self._encryption.decrypt_object(
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\PyPDF2\_encryption.py", line 744, in decrypt_object
    return cf.decrypt_object(obj)
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\PyPDF2\_encryption.py", line 185, in decrypt_object
    obj[dictkey] = self.decrypt_object(value)
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\PyPDF2\_encryption.py", line 179, in decrypt_object
    data = self.strCrypt.decrypt(obj.original_bytes)
  File "C:\Users\56663\AppData\Roaming\Python\Python310\site-packages\PyPDF2\_encryption.py", line 87, in decrypt
    d = aes.decrypt(data)
  File "C:\Users\56663\AppData\Roaming\Python\Python310\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

I'm 99% positive the PDF is not encrypted.

Thanks for any suggestions.

edit: The PDF was created using Word in Microsoft Office Professional Plus 2019.

0 Answers
Related