Drop support for Tesseract 4 alpha releases without textonly_pdf (mostly)

hocr renderer can still be used
This commit is contained in:
James R. Barlow
2019-06-03 01:39:41 -07:00
parent e73740ae9d
commit 98a3fda1f5
2 changed files with 11 additions and 11 deletions
+11 -1
View File
@@ -106,6 +106,14 @@ def check_options_output(options):
if options.pdf_renderer == 'auto':
options.pdf_renderer = 'sandwich'
if options.pdf_renderer == 'sandwich' and not tesseract.has_textonly_pdf(
options.tesseract_env
):
raise MissingDependencyError(
"You are using an alpha version of Tesseract 4.0 that does not support "
"the textonly_pdf parameter. We don't support versions this old."
)
if options.output_type == 'pdfa':
options.output_type = 'pdfa-2'
@@ -216,7 +224,9 @@ def check_options_advanced(options):
"--pdfa-image-compression argument has no effect when "
"--output-type is not 'pdfa', 'pdfa-1', or 'pdfa-2'"
)
if tesseract.v4() and (options.user_words or options.user_patterns):
if tesseract.v4(options.tesseract_env) and (
options.user_words or options.user_patterns
):
log.warning('Tesseract 4.x ignores --user-words, so this has no effect')
-10
View File
@@ -103,16 +103,6 @@ def _weave_layers_graft(
pdf_text = pikepdf.open(text)
pdf_text_contents = pdf_text.pages[0].Contents.read_bytes()
if not tesseract.has_textonly_pdf():
# If we don't have textonly_pdf, edit the stream to delete the
# instruction to draw the image Tesseract generated, which we do not
# use.
stream = bytearray(pdf_text_contents)
pattern = b'/Im1 Do'
idx = stream.find(pattern)
stream[idx : (idx + len(pattern))] = b' ' * len(pattern)
pdf_text_contents = bytes(stream)
base_page = pdf_base.pages.p(page_num)
# The text page always will be oriented up by this stage but the original