RTLBook

The engine that turns right-to-left PDFs into EPUB books, Farsi first. Open source, and behind every book on FarsiEPUB.

Most Farsi books online are PDFs: a picture of each printed page, with stored text that is rarely usable. RTLBook reads every page and builds the book again as text, an EPUB that fits any screen (why an EPUB reads better).

How it works

One page of Three Drops of Blood, Sadegh Hedayat’s stories, from a scan of the 1932 printing, as RTLBook turns it into a book.

  1. A paragraph of a 1932 Farsi book as scanned: eight lines of grey letterpress type, slightly uneven.
    The scan. A PDF of a scanned book is only pictures of its pages. There is no text in it to search or resize.
  2. The same paragraph with a turquoise box drawn round each of its eight lines.
    Lines found. RTLBook finds each line of text on the page and puts them in reading order, right to left and top to bottom.
  3. Three lines of the scan, each with what RTLBook read from it below in a turquoise box, as typed Farsi text.
    Letters read. Each line goes to an OCR reader, such as Tesseract OCR or ParisaOCR.
  4. The same paragraph as an EPUB page at a phone's width: clear Farsi type, justified, the lines running right to left.
    The book. The lines become paragraphs, with the spacing Farsi needs, in an EPUB 3 that fits any screen. This is the EPUB’s own page and font.
What it doesReads every page, builds a valid EPUB 3
  • Reads every page. PDFs exported from a word processor and scanned books, with an OCR reader.
  • Builds a proper EPUB 3. The open format, supported on most e-readers, phones and computers, and in web browsers. Right-to-left page direction, a Farsi font, a cover, contents, and the printed page numbers. Every book is checked with epubcheck.
  • Fixes the spacing. The half-spaces Farsi needs before endings and after prefixes, and words a scan ran together.
Try itOnline on FarsiEPUB, or on your own computer

Without installing anything: upload a PDF here on FarsiEPUB, which runs RTLBook for you, free.

On your own computer. RTLBook is free and open source, on GitHub under the Apache License 2.0 (the name and logo are not covered by it). You need Docker, and the README walks you from a clone to a book: build the image once, put your PDF in input/, and convert it. A 95-page exported PDF took under a minute on a Mac; a scan takes about five times as long. Open the EPUB in Thorium Reader, or in any app built on Readium.

It is for developers and publishers who want to convert books themselves, many at once, or with their own settings.

Known limitsFarsi only so far, scans measured on few books
  • Farsi only. Arabic, Urdu and Hebrew are planned, not built.
  • Scans are measured on few books. On hand-checked pages of a 1932 scan, 3 letters in 1,000 were misread. Typewritten books aren’t measured yet, and decorative frames can turn into stray lines.
  • Check the title and author. They are read from the title page when it has them as text.
Questions and helpEmail, or an issue on GitHub

Write to contact@farsiepub.org, or open an issue on GitHub. How it works is in DESIGN.md, and what comes next in the roadmap.