diff --git a/ocrmypdf/__main__.py b/ocrmypdf/__main__.py index 234f4a9b..4ecbc381 100755 --- a/ocrmypdf/__main__.py +++ b/ocrmypdf/__main__.py @@ -356,9 +356,6 @@ def check_options(options, log): sys.exit(ExitCode.missing_dependency) - - - # ---------- # Logging diff --git a/tests/resources/README.rst b/tests/resources/README.rst index fd515361..a321515d 100644 --- a/tests/resources/README.rst +++ b/tests/resources/README.rst @@ -64,6 +64,9 @@ under the terms of the license in LICENSE.rst. * - epson.pdf - @lowesjam - a linearized PDF containing some unusual indirect objects, created by an Epson printer; printout of a Wikipedia article (CC BY-SA) + * - formxobject.pdf + - @jbarlow83 + - hand-crafted exotic PDF containing an image inside a Form XObject * - francais.pdf - @jbarlow83 - a page containing French accents (diacritics) diff --git a/tests/resources/formxobject.pdf b/tests/resources/formxobject.pdf new file mode 100644 index 00000000..7c9044d5 Binary files /dev/null and b/tests/resources/formxobject.pdf differ diff --git a/tests/test_main.py b/tests/test_main.py index e0ed6ce1..82fc1f67 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -742,3 +742,9 @@ THIS FILE IS INVALID '--tesseract-config', str(cfg_file)) assert "parameter not found" in err, "No error message" assert p.returncode == ExitCode.invalid_config + + +def test_form_xobject(spoof_tesseract_noop, resources, outpdf): + check_ocrmypdf(resources / 'formxobject.pdf', outpdf, + '--force-ocr', + env=spoof_tesseract_noop) diff --git a/tests/test_pageinfo.py b/tests/test_pageinfo.py index eda7e276..dcb4ab90 100644 --- a/tests/test_pageinfo.py +++ b/tests/test_pageinfo.py @@ -101,3 +101,10 @@ def test_jpeg(resources, outdir): assert pdfimage['enc'] == 'jpeg' assert (pdfimage['dpi_w'] - 150) < 1e-5 + +def test_form_xobject(resources): + filename = resources / 'formxobject.pdf' + + pdfinfo = pageinfo.pdf_get_all_pageinfo(str(filename)) + pdfimage = pdfinfo[0]['images'][0] + assert pdfimage['width'] == 50