Split PDF pages in half, tested on book scans
196 fewer
words with a middle cut, seam off center
Cut at the gutter, not the middle
| Way | Seam at 50% | Seam at 40% |
|---|---|---|
| split-half.py | 1,877 | 1,876 |
| Cut at the middle | 1,879 | 1,680 |
| unpaper | 1,875 | 1,763 |
| No split | 1,680 | 1,879 |
5 two-page spreads made from 10 real scanned book pages. Cut at the middle is a crop at 50% of the width, where mutool, pypdf and Stirling-PDF all cut.
- With the seam at 40%, the middle cut runs through the right page. All 5 spreads lost words.
- Read whole, one centered spread lost most of its right page: Tesseract found 12 of its 197 words.
split-half.py finds the gutter
It looks for the widest band with almost no ink between 30% and 70% of the width, and cuts at its darkest column. With no band, it cuts at the middle.
python3 -m venv venv && . venv/bin/activate
pip install pymupdf numpy
python3 split-half.py in.pdf out.pdf
- It prints each cut. On our 40% set: 40.1% to 40.5%.
- The pictures stay as they are, so the file stays about the same size.
- A text layer is split too. MIT license.
Other tools keep the hidden half
| Way | Words, pypdf |
|---|---|
| The spreads, before the split | 1,855 |
| mutool, pypdf, Stirling-PDF | 3,710 |
| split-half.py | 1,855 |
| ImageMagick | 0 |
mutool, pypdf and Stirling-PDF show one side, but each half still holds the text of the whole spread. So every OCR word is in the file twice.
pdftotext reads only the visible half, but pypdf's extract_text reads both. ImageMagick turns pages into pictures: no text, and 7.4 MB became 178 MB.
Split first, then OCR
| Order | Of 1,955 |
|---|---|
| Split, then OCR | 1,857 |
| OCR the spreads, then split | 1,672 |
| OCR the spreads, no split | 1,408 |
On 2 of the 5 whole spreads, the text layer jumps between the two pages. A split after OCR fixes that order, but it cannot add the words OCR missed.
python3 split-half.py in.pdf halves.pdf
ocrmypdf halves.pdf searchable.pdf
If the spreads already have OCR, split them and add
--force-ocr: 1,861 words on mutool's halves.
Our Actor reads whole spreads too
Our Apify Actor turns a scanned PDF into Markdown. On the whole spreads its code found 1,884 and 1,875 words, about the same as on the halves.
The free plan takes 20 pages a run, 50 a month. A scanned page costs $0.006, and pages with a text layer are free.
How I tested it
- Pages: scan B of our open source OCR test, 10 proofread Wikisource book pages. Each pair became one spread with a spine shadow, at 300 dpi.
- The 40% set has a dark band on the right, like an open scanner lid. These are made-up spreads, not scans of open books: no page curl.
- Tesseract 5.5.4, English, on a Mac. Words found in order, so text out of order counts as missed.
- The Cut at the middle row is Tesseract on crops. mutool's own PDF, rendered at 300 dpi, gave 1,882 on the centered set.
- mutool 1.25.1 and ImageMagick 7.1.1 (Debian 13 in Docker), pypdf 7.1.1, the Stirling-PDF image of Nov 19, unpaper 7.0.0, OCRmyPDF 17.13.0, PyMuPDF 2.1.
- Not tested: Briss, pdfposter, online tools, page curl, right to left books.
Questions people ask
How do I split PDF pages in half vertically?
For a left and a right page, mutool poster -x 2 in.pdf out.pdf cuts each page at the middle. For scanned books, split-half.py cuts at the gutter instead.
Should I split a scanned book before OCR?
It helped on our centered spreads: OCRmyPDF found 1,857 of 1,955 words in order after the split, and 1,408 on the whole spreads. On the off-center set, whole spreads read as well as halves.
Does splitting a PDF page keep the OCR text?
mutool, pypdf and Stirling-PDF keep all of it on both halves: 3,710 words in the file, from 1,855. split-half.py keeps each half's own text.