Fix running without eng.traineddata installed raises exception

This commit is contained in:
James R. Barlow
2019-08-27 14:54:03 -07:00
parent 638eb556ef
commit 11ef78a891
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -61,13 +61,13 @@ def v4(tesseract_env=None):
return version(tesseract_env) >= '4'
def has_textonly_pdf(tesseract_env=None):
def has_textonly_pdf(tesseract_env=None, langs=None):
"""Does Tesseract have textonly_pdf capability?
Available in v4.00.00alpha since January 2017. Best to
parse the parameter list
parse the parameter list.
"""
args_tess = ['tesseract', '--print-parameters', 'pdf']
args_tess = tess_base_args(langs, engine_mode=None) + ['--print-parameters', 'pdf']
params = ''
try:
proc = run(
@@ -358,7 +358,7 @@ def generate_pdf(
if pagesegmode is not None:
args_tesseract.extend(['--psm', str(pagesegmode)])
if text_only and has_textonly_pdf(tesseract_env):
if text_only and has_textonly_pdf(tesseract_env, language):
args_tesseract.extend(['-c', 'textonly_pdf=1'])
if user_words: