k2pdfopt for a Kindle: reflow and OCR, tested
2.3x
taller text on a Kindle, when it reflows
One flag doubled the pages it reflowed
| Scans | Defaults | With -wt+ 100 |
|---|---|---|
| Book, white paper | 5 of 5 | 5 of 5 |
| Book, dark paper | 0 of 5 | 5 of 5 |
| Two columns | 1 of 5 | 2 of 5 |
Reflowed means words at least 1.5 times as tall as on the whole page, at the same size. It came out 2.2 to 2.7 times as tall.
-
On dark paper, it split each page over 2 screens without reflowing,
until
-wt+ 100made the paper count as white. - Pages from the 1911 Britannica and the 1879 American Cyclopaedia never reflowed: text grew 1.4 times at most.
Run it on a Mac with Docker
Debian 13 packages k2pdfopt 2.55, and Docker runs it on Apple silicon.
Save this as Dockerfile:
FROM debian:trixie-slim
RUN apt-get update && apt-get install -y --no-install-recommends k2pdfopt && rm -rf /var/lib/apt/lists/*
WORKDIR /work
ENTRYPOINT ["k2pdfopt"]
Build it once, then convert a PDF in the same folder:
docker build -t k2pdfopt .
docker run --rm -v "$PWD":/work k2pdfopt -ui- -x -dev kp3 -o book-kindle.pdf book.pdf
-
-dev kp3is k2pdfopt's Paperwhite 3 size, 1016 by 1364 pixels. -
For dark paper, add
-wt+ 100before-o. - Its home page is willus.com. I did not test builds from there.
Its OCR crashed: run OCRmyPDF first
-ocr t stopped with exit code 139, a crash, on both sets.
It left a file of 116 bytes.
k2pdfopt carries over most of a text layer it finds, so OCR the scan first:
ocrmypdf -l eng book.pdf book-ocr.pdf
docker run --rm -v "$PWD":/work k2pdfopt -ui- -x -dev kp3 -o book-kindle.pdf book-ocr.pdf
| Way | Book | Two columns |
|---|---|---|
| k2pdfopt alone | 0 | 0 |
| OCRmyPDF | 1,874 | 5,820 |
| OCRmyPDF, then k2pdfopt | 1,790 | 4,654 |
| Our Actor, as an EPUB | 1,879 | 5,825 |
| True words | 1,955 | 6,031 |
- On two columns, 5,789 of the words were there in some order.
-
Plain
pdftotext, without-raw, found only 960 book words in order.
Our Actor: text that fits any screen
Our Apify Actor reads scans into Markdown. pandoc makes that an EPUB, and the reader picks the text size.
pandoc book.md -o book.epub --metadata title=Scan
It gives text, not the page picture. A scanned page costs $0.006, and pages with a text layer are free.
How I tested it
- 10 proofread book pages from Wikisource, 2 public domain books, 1,955 words. Half are on darker paper.
- 5 two-column encyclopedia pages: the 1911 Britannica twice, the New International, the 1879 American Cyclopaedia and Collier's. 6,031 words.
- Real scans, kept as JPEG inside a PDF. The screen picture is book page 86.
- k2pdfopt 2.55 from Debian 13 (arm64) in Docker, 2 CPUs, one page at a time for the reflow count.
- Taller text: the median Tesseract word height on its pages, against the whole page fitted to the same screen.
-
Words: true words found in order, read with
pdftotext -rawor from the EPUB. Extra words cost nothing. -
-ocr gcrashed too, and so did the amd64 build, emulated, on 1 page. The OCR runs also had Debian's tesseract-ocr-eng. Debian 12's 2.54 said "tesseract unsupported" and added no text. -mode 2colreflowed 1 of 15.- OCRmyPDF 17.13.0 with Tesseract 5.5.4. The Actor's code at build 0.1.97 ran on the page images on our Mac.
- Not tested: willus.com builds, Windows, the k2pdfopt menu, other flags, search on a Kindle.
Questions people ask
Does k2pdfopt work on a Mac?
Yes, in Docker. Debian's k2pdfopt 2.55 ran on Apple silicon and reflowed 12 of 15 test scans with -wt+ 100. I did not test the builds on willus.com.
Can k2pdfopt OCR a scanned PDF?
Its -ocr t crashed with exit code 139 in Debian's 2.55. Run OCRmyPDF first: k2pdfopt then kept 1,790 of 1,955 book words in order.
What is a good k2pdfopt alternative?
For text that fits any screen, OCR the scan to Markdown and make an EPUB with pandoc. KOReader's team keeps a k2pdfopt library for its e-reader app. I did not test it.