diff --git a/src/ocrmypdf/_exec/tesseract.py b/src/ocrmypdf/_exec/tesseract.py
index 4eac3470..c7bd761c 100644
--- a/src/ocrmypdf/_exec/tesseract.py
+++ b/src/ocrmypdf/_exec/tesseract.py
@@ -26,25 +26,6 @@ from ocrmypdf.subprocess import get_version, run
log = logging.getLogger(__name__)
-HOCR_TEMPLATE = """
-
-
-
-
-
-
-
-
-
-
-
-
-
-"""
-
TESSERACT_THRESHOLDING_METHODS: dict[str, int] = {
'auto': 0,
'otsu': 0,
@@ -284,14 +265,11 @@ def page_timedout(timeout: float) -> None:
def _generate_null_hocr(output_hocr: Path, output_text: Path, image: Path) -> None:
- """Produce a .hocr file that reports no text detected.
+ """Produce an empty .hocr file.
Ensures page is the same size as the input image.
"""
- with Image.open(image) as im:
- w, h = im.size
-
- output_hocr.write_text(HOCR_TEMPLATE.format(w, h), encoding='utf-8')
+ output_hocr.write_text('', encoding='utf-8')
output_text.write_text('[skipped page]', encoding='utf-8')
diff --git a/src/ocrmypdf/_pipeline.py b/src/ocrmypdf/_pipeline.py
index 8029d510..d9cc87fd 100644
--- a/src/ocrmypdf/_pipeline.py
+++ b/src/ocrmypdf/_pipeline.py
@@ -734,6 +734,11 @@ def render_hocr_page(hocr: Path, page_context: PageContext) -> Path:
"""Render the hOCR page to a PDF."""
options = page_context.options
output_file = page_context.get_path('ocr_hocr.pdf')
+ if hocr.stat().st_size == 0:
+ # If hOCR file is empty (skipped page marker), create an empty PDF file
+ output_file.touch()
+ return output_file
+
dpi = get_page_square_dpi(page_context, calculate_image_dpi(page_context))
debug_mode = options.pdf_renderer == 'hocrdebug'
diff --git a/tests/test_tesseract.py b/tests/test_tesseract.py
index f5fe01d6..69d18202 100644
--- a/tests/test_tesseract.py
+++ b/tests/test_tesseract.py
@@ -86,7 +86,7 @@ def test_image_too_large_hocr(monkeypatch, resources, outdir):
user_words=None,
user_patterns=None,
)
- assert "name='ocr-capabilities'" in Path(outdir / 'out.hocr').read_text()
+ assert Path(outdir / 'out.hocr').read_text() == ''
def test_image_too_large_pdf(monkeypatch, resources, outdir):