Refolio
Turn scans of bound books into clean, searchable PDFs — without changing a glyph.
日本語 · Beta (pre-release) · Guide: yoshida-kd.github.io/refolio
You scanned or photocopied a book, open as spreads or page by page. Refolio makes a PDF that is easier to read:
each spread split into its two pages at the gutter, straightened, trimmed, placed on one standard paper size with
the text block at the same place on every page, the binding shadow and the paper grain taken away, and, if you
want, an invisible text layer for search and copy. It runs on your machine; nothing is uploaded.
- Spreads or single pages. A scan wider than tall is split at the gutter: in the blank band between the two
pages, found on the shadow-flattened image, so text printed into the shadow is not cut.
- Page curl near the spine. Lines that bend toward the spine are straightened and squeezed glyphs are widened,
where the curl is visible.
- One book, one layout. A standard paper size (A6–A3, B6–B4, Letter) is chosen from the size of the pages;
you can pick another. The text block sits at the same place on every page.
- Clean pages. The binding shadow is removed, the paper becomes white and its grain is smoothed. The black
scanner ground in the corners and the edges of the other pages beside the page are wiped.
- Searchable, if you want. Turn on
refolio.textLayer for an invisible text layer from
NDLOCR-Lite (National Diet Library, Japan), made for Japanese print.
It is off by default: the text recognition takes about 0.5 GB and about doubles the time.
- Super-resolution. Grey pages scanned below 300 dpi are enlarged on your GPU (Real-ESRGAN), and a page is
used only if every glyph keeps its shape (the glyph guard).
- Colour and 1-bit pages stay colour and 1-bit.
- A PDF viewer for the result, shared with the Octavo extension when both are installed.
How Refolio treats your scans
Refolio never draws a glyph. Every step either moves pixels geometrically (split, rotate, trim, flatten the curl,
place on the paper) or multiplies them by a smooth brightness gain (shadow, paper). Super-resolution is the only
step that makes new pixels, and its pages are checked glyph by glyph against the scan. Your scan is never
overwritten: the result goes next to it (book.pdf → book.refolio.pdf).
Getting started
- Install the extension and open the Refolio view in the activity bar.
- Click Set up. Refolio installs its own Python environment with uv
(shipped with the extension) and the super-resolution engine: about 0.4 GB on disk, once.
- Right-click a scanned PDF in the Explorer → Refolio: Make a clean PDF, or run it from the Command Palette.
When it is done, Open shows the result in the viewer; it is also listed in the Refolio view.
A 600 dpi book of 76 pages takes about two minutes on a desktop CPU.
The text layer
Turn on Refolio: Text Layer (refolio.textLayer) in the settings. The next time you make a PDF, Refolio offers
to install the text recognition (NDLOCR-Lite and its models, about 0.5 GB). To read on an NVIDIA GPU, run
refolio setup --ocr --gpu in a terminal instead. It installs onnxruntime-gpu with the CUDA and cuDNN libraries
(about 2.4 GB more, under NVIDIA's licenses). Refolio then reads on the GPU and falls back to the CPU if that fails.
Settings
| Setting |
Default |
|
refolio.textLayer |
off |
An invisible text layer for search and copy (installs the text recognition when first used). |
refolio.superResolution |
on |
Super-resolution for grey pages scanned below 300 dpi, when its engine is installed. |
refolio.quality |
80 |
JPEG quality of the pages. |
refolio.outputFolder |
empty |
Where results go: empty is beside the scan; a name such as out is that folder beside the scan; an absolute path is that folder. |
refolio.outputName |
{name}.refolio |
The name of a result; {name} is the name of the scan. |
refolio.command |
empty |
A refolio command to use instead of the environment the extension sets up. |
refolio.installFrom |
empty |
What Set up installs instead of the matching refolio from PyPI. |
For AI agents and the command line
Everything the extension does goes through the refolio command (also on PyPI: pip install --pre refolio). After
Set up, it is on the PATH of VS Code's terminal. With --json it prints JSON Lines (progress, then one
result or error), and refolio docs prints a reference written for AI agents, so Claude Code or any agent
can run it for you:
refolio make book.pdf book.refolio.pdf --json
refolio make book.pdf out.pdf --size b5 --ocr off
Beta: what is not there yet
- Vertical text (right-bound books). Pages come out in left-to-right order unless you give
--binding right on the command line; the extension does not detect it yet.
- Overhead scanners (ScanSnap SV600 and the like): not tested yet.
- Text printed into the binding, or hidden in the fold when the copy was made, cannot be recovered. Press the
book flat at the spine when you scan or copy it.
- Tested mostly on Linux. macOS and Windows builds will follow.
Licenses
Refolio is under the MIT License. uv (MIT or Apache-2.0) and PDF.js (Apache-2.0) are shipped with it; NDLOCR-Lite
(CC BY 4.0), Real-ESRGAN (BSD-3-Clause) and the Python packages are downloaded when you set it up. See
THIRD_PARTY_NOTICES.md.