Write us on Telegram@Odilient

AI & AUTOMATION

Knigopoisk Large-Print Pipeline

A Python pipeline that turns scanned, OCR-layered PDF books into clean large-print PDFs, reflowable EPUBs and catalog covers for a Russian-language online bookstore.

Knigopoisk
Client
Books & Publishing
Industry
2026
Year
Where it started

The Challenge

Some books exist only as scanned PDFs with an OCR text layer: fixed page images, soft hyphens and recognition errors such as Latin letters inside Cyrillic words. Readers with low vision need the same book reflowed at a large point size, and an e-book store also needs a reflowable EPUB and a presentable cover, without retyping hundreds of pages by hand.

What we did

The Solution

We built a five-step Python pipeline on PyMuPDF, ReportLab, Pillow and NumPy. It extracts every text line with coordinates, glues lines into paragraphs, strips soft hyphens, fixes typical OCR confusions, detects parts and chapters by heading size and cuts out figures by their captions. From one intermediate structure it writes an EPUB and a PDF at any point size, switching to a large-print layout at 18 pt and above, plus a 2:3 catalog cover.

Built with
PythonPyMuPDFReportLabPillowNumPyEPUB
Inside the build

How It Came Together

Turning scanned PDFs into large-print PDF and EPUB editions

For Knigopoisk, a Russian-language e-book and audiobook store, we built a pipeline that converts a scanned PDF book with an OCR text layer into accessible editions: a large-print PDF at a chosen point size, a reflowable EPUB and a cover image in the 2:3 format the storefront's book cards expect. It is internal production tooling rather than a customer-facing feature.

How the pipeline works

  1. Extract — extract.py reads the PDF with PyMuPDF and writes every text line with its page coordinates to rows.json.
  2. Rebuild structure — build3.py glues lines into paragraphs, removes soft hyphens and repairs typical OCR confusions, such as misread Cyrillic letters and Latin characters inside Cyrillic words. It detects parts, chapters and sections from heading font sizes and extracts figures into images by their "Рис. N" captions.
  3. Write outputs — make_outputs.py turns the block list into sections and an EPUB.
  4. Typeset — make_pdf.py <pt> sets the book with ReportLab on A4 in DejaVu Sans. At 18 pt and above it builds the large-print edition with tighter margins; smaller sizes produce a regular reading edition. Headings scale from the body size, widows and orphans are suppressed, and every page gets a number, with PDF outline bookmarks for navigation.
  5. Cover — make_cover.py renders the source title page at 300 dpi, trims the scan's margins down to the type block and frames it as an 800×1200 JPEG.

Results on the first book

We ran the pipeline end to end on a scanned Russian-language management book of more than 250 pages. Extraction produced 10,004 text lines; the structure pass rebuilt 1,589 paragraphs, 4 parts, 15 chapters and 14 figures; and the output step wrote 29 sections and a 1.6 MB EPUB. Each stage logs its counts, which makes the output easy to review before anything reaches the catalog.

This tooling sits alongside our other AI integration and automation work for Knigopoisk, including the AI audiobook generation pipeline and the Knigopoisk partner widget.

Let's Build

Want something like Knigopoisk Large-Print Pipeline?

Tell us what your product needs to do. We'll shape the scope, map a timeline and send a fixed price — free, and with no obligation to proceed.

Free consultation No commitment Fast reply