Docs / Guides
Multi-Page and Merge
Two related but different things: converting many separate files in one call (batch), and combining several pages into a single multi-page PDF (merge). A native PDF as input touches both.
Batch conversion
Multiple inputs plus a folder as -o converts each file independently,
one output per input.
bash
scanlayer *.jpg -o ./converted/
pythonbatch.py
result = scanlayer.convert_batch(["*.jpg"], "./converted/")
A single bad file does not abort the batch. CLI exit code 5 signals a
partial failure; in the library, check BatchResult.failures. See
Library API → convert_batch().
--merge: one PDF from many pages
bash
scanlayer a.jpg b.jpg -o combined.pdf --merge
pythonmerge.py
scanlayer.convert_merge(["a.jpg", "b.jpg"], "combined.pdf")
Combines multiple images into one multi-page PDF, in argument order.
PDF-only
--merge only supports --format pdf / output_format="pdf", since there is no single sensible multi-page schema for txt/json/tsv/hocr. -o / output_path must be a file path, not a folder, when merging.
Native PDF input
A .pdf file given as input is automatically rasterized page by page
(via pdf2image/poppler) before OCR.
| With --merge | Without --merge |
|---|---|
| Re-runs OCR over an existing PDF and gets one PDF back out. | Gets one output file per source page. |
Requires poppler on PATH
See Installation. If it is missing, scanlayer raises
DependencyError with an actionable message rather than a cryptic subprocess failure.
bash
# one output file per page
scanlayer scanned-report.pdf -o ./pages/
# re-OCR the whole document into a single merged PDF
scanlayer scanned-report.pdf -o ocred-report.pdf --merge
pythonpdf_input.py
scanlayer.convert_batch(["scanned-report.pdf"], "./pages/")
# merge=True on convert_batch goes straight from a PDF's pages
# to one merged, re-OCR'd PDF:
scanlayer.convert_batch(
["scanned-report.pdf"], "ocred-report.pdf", merge=True,
)