How to use the ocrmypdf.exec.qpdf function in ocrmypdf

To help you get started, we’ve selected a few ocrmypdf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jbarlow83 / OCRmyPDF / tests / test_qpdf.py View on Github external
def test_qpdf_error(resources):
    assert qpdf.check(resources / 'blank.pdf')
    assert not qpdf.check(__file__)
github jbarlow83 / OCRmyPDF / tests / test_qpdf.py View on Github external
def test_qpdf_error(resources):
    assert qpdf.check(resources / 'blank.pdf')
    assert not qpdf.check(__file__)
github jbarlow83 / OCRmyPDF / tests / test_stdio.py View on Github external
input_file = str(resources / 'francais.pdf')
    output_file = str(outpdf)

    # Runs: ocrmypdf francais.pdf - > test_stdout.pdf
    with open(output_file, 'wb') as output_stream:
        p_args = ocrmypdf_exec + [input_file, '-']
        p = run(
            p_args,
            stdout=output_stream,
            stderr=PIPE,
            stdin=DEVNULL,
            env=spoof_tesseract_noop,
        )
        assert p.returncode == ExitCode.ok

    assert qpdf.check(output_file, log=None)
github jbarlow83 / OCRmyPDF / tests / test_hocrtransform.py View on Github external
def test_mono_image(blank_hocr, outdir):
    im = Image.new('1', (8, 8), 0)
    for n in range(8):
        im.putpixel((n, n), 1)
    im.save(outdir / 'mono.tif', format='TIFF')

    hocr = hocrtransform.HocrTransform(str(blank_hocr), 300)
    hocr.to_pdf(str(outdir / 'mono.pdf'), imageFileName=str(outdir / 'mono.tif'))

    qpdf.check(str(outdir / 'mono.pdf'))
github jbarlow83 / OCRmyPDF / tests / test_main.py View on Github external
    '8.0.0' <= qpdf.version() <= '8.0.1',
    reason="qpdf regression on pages with no contents",
)
def test_no_contents(spoof_tesseract_noop, resources, outpdf):
    check_ocrmypdf(
        resources / 'no_contents.pdf', outpdf, '--force-ocr', env=spoof_tesseract_noop
    )