Add helpful error message for PDFs that use algorithm 4

This commit is contained in:
James R. Barlow
2016-06-23 13:13:17 -07:00
parent 5022ded276
commit bbd02926e1
2 changed files with 14 additions and 0 deletions
+1
View File
@@ -11,6 +11,7 @@ class ExitCode(IntEnum):
file_access_error = 5
already_done_ocr = 6
child_process_error = 7
encrypted_pdf = 8
other_error = 15
+13
View File
@@ -1078,6 +1078,19 @@ def do_ruffus_exception(ruffus_five_tuple):
ocrmypdf --pdf-renderer tesseract [..other args..]
"""))
return ExitCode.input_file
elif exc_name == 'PyPDF2.utils.PdfReadError' and \
'not been decrypted' in exc_value:
_log.error(textwrap.dedent("""\
Input PDF uses either an encryption algorithm or a PDF security
handler that is not supported by ocrmypdf.
For information about this PDF's security use
qpdf --show-encryption [...input PDF...]
(Only algorithms "R = 1" and "R = 2" are supported.)
"""))
return ExitCode.encrypted_pdf
elif not options.verbose:
_log.error(exc_stack)
return ExitCode.other_error