2022-07-28 01:06:46 -07:00
|
|
|
# SPDX-FileCopyrightText: 2022 James R. Barlow
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
2017-05-25 00:07:29 -07:00
|
|
|
|
2022-07-23 00:39:24 -07:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2018-12-30 01:28:15 -08:00
|
|
|
from math import isclose
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2019-03-06 13:28:50 -08:00
|
|
|
from ocrmypdf.pdfinfo import PdfInfo
|
2017-05-25 00:07:29 -07:00
|
|
|
|
2024-02-14 12:41:51 -08:00
|
|
|
from .conftest import check_ocrmypdf
|
2020-06-09 15:27:14 -07:00
|
|
|
|
|
|
|
# pylint: disable=redefined-outer-name
|
2017-05-25 00:07:29 -07:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def poster(resources):
|
|
|
|
return resources / 'poster.pdf'
|
|
|
|
|
|
|
|
|
2023-04-29 00:42:38 -07:00
|
|
|
@pytest.mark.parametrize("mode", ['pdf', 'pdfa'])
|
|
|
|
def test_userunit_pdf_passes(mode, poster, outpdf):
|
2017-05-25 01:17:43 -07:00
|
|
|
before = PdfInfo(poster)
|
2020-06-05 17:45:11 -07:00
|
|
|
check_ocrmypdf(
|
|
|
|
poster,
|
|
|
|
outpdf,
|
2023-04-29 00:42:38 -07:00
|
|
|
f'--output-type={mode}',
|
2020-06-05 17:45:11 -07:00
|
|
|
'--plugin',
|
|
|
|
'tests/plugins/tesseract_cache.py',
|
|
|
|
)
|
2017-05-25 01:17:43 -07:00
|
|
|
|
|
|
|
after = PdfInfo(outpdf)
|
|
|
|
assert isclose(before[0].width_inches, after[0].width_inches)
|
|
|
|
|
2017-05-29 13:01:18 -07:00
|
|
|
|
2020-06-05 17:45:11 -07:00
|
|
|
def test_rotate_interaction(poster, outpdf):
|
2018-12-30 01:27:49 -08:00
|
|
|
check_ocrmypdf(
|
2020-06-05 17:45:11 -07:00
|
|
|
poster,
|
|
|
|
outpdf,
|
|
|
|
'--output-type=pdf',
|
|
|
|
'--rotate-pages',
|
|
|
|
'--plugin',
|
|
|
|
'tests/plugins/tesseract_cache.py',
|
2018-12-30 01:27:49 -08:00
|
|
|
)
|