Raise exception if resulting PDF might appear blank in a known in some PDF viewers

Fixes #1187
This commit is contained in:
James R. Barlow
2023-11-09 22:33:22 -08:00
parent e7fa97731f
commit a596ccf844
5 changed files with 37 additions and 7 deletions
+11 -1
View File
@@ -13,7 +13,7 @@ import pytest
from PIL import Image, UnidentifiedImageError
from ocrmypdf._exec.ghostscript import DuplicateFilter, rasterize_pdf
from ocrmypdf.exceptions import ExitCode
from ocrmypdf.exceptions import ColorConversionNeededError, ExitCode
from ocrmypdf.helpers import Resolution
from .conftest import check_ocrmypdf, run_ocrmypdf_api
@@ -126,6 +126,16 @@ def test_ghostscript_feature_elision(resources, outpdf):
)
def test_ghostscript_mandatory_color_conversion(resources, outpdf):
with pytest.raises(ColorConversionNeededError):
check_ocrmypdf(
resources / 'jbig2_baddevicen.pdf',
outpdf,
'--plugin',
'tests/plugins/tesseract_noop.py',
)
def test_rasterize_pdf_errors(resources, no_outpdf, caplog):
with patch('ocrmypdf._exec.ghostscript.run') as mock:
# ghostscript can produce