Convert scanned Arabic PDF books into e-reader friendly EPUBs (OCR or optimized images)
Project description
arabic-pdf2ebook 📖
Convert scanned Arabic PDF books into EPUBs you can actually read on any e-reader.
🇸🇦 اقرأ الدليل الكامل بالعربية: README.ar.md
| Before: scanned PDF page | After: real resizable text | The local web page |
|---|---|---|
Old scanned Arabic books (from Noor-Book, kotob.has.it, archive.org…) are image-only PDFs: on a small e-reader the text is tiny, blurry, and can't be resized. This tool fixes that — locally, for free, with no cloud upload.
✨ Features
- Text mode (OCR) — recognizes the Arabic text and builds a reflowable right-to-left EPUB:
resizable text, embedded Amiri font, correct RTL page turning, table of contents,
automatic removal of watermarks (
http://kotob.has.it/…) and page numbers. - Classical poetry & Quranic quotes — rhymed verse blocks (قصائد) are detected and kept one بيت per centered line instead of being flattened into prose; Quranic quotes get their ornate brackets ﴿…﴾ restored and distinct styling when the book marks them (قرآن كريم, سورة…).
- Image mode — no OCR: cleans each page (deskew, denoise, contrast, margin crop), resizes it for your reader's screen, and packs the pages into an EPUB (and optionally CBZ). 100 % faithful to the original print.
- Auto mode (default) — uses the PDF's own text layer when it exists and is healthy (many books embed a broken one — we detect that), OCRs the rest, and keeps photos/maps/failed pages as cleaned images so you never get garbage text.
- Huge books welcome — pages stream one at a time (a 2,400-page book converts in constant memory), every stage is cached and resumable, and output can be split into volumes.
- Local web page —
pdf2ebook uiopens a friendly bilingual drag-and-drop page in your browser. Everything still runs on your own computer. - Wi-Fi send —
pdf2ebook send book.epubuploads straight to a CrossPoint e-reader (Xteink X3/X4). - Arabic font included, everywhere — every EPUB embeds the Amiri font (phones, Apple
Books, Kobo render Arabic with zero setup). For readers with no Arabic support at all,
the font ships ready-to-install:
pdf2ebook fonts install --host <reader-ip>puts it on a CrossPoint reader over Wi-Fi (pair with--preshape), andpdf2ebook fonts exportwrites a folder with the TTF + instructions for Kobo and others. Full per-device guide: docs/devices.md.
🚀 Quick start
# 1. install the tool (Python 3.10+)
pip install arabic-pdf2ebook
# 2. install Tesseract OCR (needed for text mode only)
# Windows:
winget install UB-Mannheim.TesseractOCR
# Linux: sudo apt install tesseract-ocr macOS: brew install tesseract
# 3. convert!
pdf2ebook convert "my-scanned-book.pdf" # auto mode → book.epub
pdf2ebook convert "my-scanned-book.pdf" --mode image # image mode (no OCR needed)
# or use the friendly web page:
pdf2ebook ui
The Arabic OCR model (ara.traineddata, best quality) is downloaded automatically on first use —
no manual setup.
🖥️ The web page
pdf2ebook ui (or just double-clicking pdf2ebook.exe from the
Releases page) opens http://127.0.0.1:8765:
drag your PDF → pick Text or Images → Convert → Download / Send over Wi-Fi.
📚 Common recipes
pdf2ebook inspect book.pdf # pages? text layer? what mode to use?
pdf2ebook convert book.pdf --pages 5-20 # test settings on a few pages first
pdf2ebook preview book.pdf --mode ocr # eyeball the cleaned page images
pdf2ebook convert book.pdf --mode image --device xteink-x4 --cbz
pdf2ebook convert big-book.pdf --split-volumes 4
pdf2ebook send book.epub --host 192.168.1.50
pdf2ebook devices # list device profiles
🎯 OCR accuracy on old prints
Old Arabic prints are hard for every OCR engine. This tool stacks the known accuracy levers:
tessdata_bestArabic model + LSTM engine- preprocessing tuned for old paper: Sauvola adaptive binarization, CLAHE contrast, denoising, deskew, margin removal, upscaling of small print
- a rescue pass that re-OCRs low-confidence pages with an alternate binarization
- a confidence gate: pages that still fail are embedded as cleaned images instead of garbage text (the conversion summary tells you how many)
When Tesseract isn't good enough, install the optional neural engine and use --engine surya:
pip install "arabic-pdf2ebook[surya]"
Expectation setting: OCR output is meant for comfortable reading, not scholarly fidelity.
For a 100 % faithful copy, use --mode image.
بالعربية
ما هذه الأداة؟
كثير من الكتب العربية القديمة متاحة فقط كملفات PDF ممسوحة ضوئيًا، فلا يمكن تكبير النص أو إعادة تدفّقه على القارئ الإلكتروني. هذه الأداة المجانية مفتوحة المصدر تحوّل تلك الكتب إلى EPUB — على جهازك مباشرة دون رفع الملفات إلى الإنترنت.
طريقتا التحويل
- وضع النص: تتعرف الأداة على النص العربي (OCR) وتبني كتاب EPUB حقيقيًا — نص قابل للتكبير، خط أميري مدمج، اتجاه من اليمين لليسار، فهرس، وحذف تلقائي للعلامات المائية وأرقام الصفحات.
- وضع الصور: بدون تعرف على النص — تنظيف كل صفحة (تسوية الميل، إزالة الضوضاء، تحسين التباين، قص الهوامش) وتحجيمها لشاشة قارئك. مطابق تمامًا للأصل.
البدء السريع
pip install arabic-pdf2ebook
winget install UB-Mannheim.TesseractOCR
pdf2ebook ui
ثم اسحب ملف PDF إلى الصفحة التي تُفتح في المتصفح، واختر طريقة التحويل، وحمّل ملف EPUB الناتج — أو أرسله مباشرة إلى قارئ CrossPoint عبر Wi-Fi.
لمن لا يريد تثبيت بايثون: حمّل pdf2ebook.exe من صفحة
الإصدارات وانقر عليه نقرًا مزدوجًا.
License
Apache-2.0 — see LICENSE. Bundled Amiri font is under the SIL OFL 1.1; see THIRD_PARTY_NOTICES.md.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arabic_pdf2ebook-0.1.3.tar.gz.
File metadata
- Download URL: arabic_pdf2ebook-0.1.3.tar.gz
- Upload date:
- Size: 403.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b4bc8d18ef8db4c0085614de9fe73d42e8361ee35b89f93b3f8532b86b360cc
|
|
| MD5 |
5723de53160681242a4f54f089d3f515
|
|
| BLAKE2b-256 |
788aa14d4bb8dbbeef7ed4e9ed95cd0e3eefd3fbb9dd2cee2f1890b50c4798cb
|
Provenance
The following attestation bundles were made for arabic_pdf2ebook-0.1.3.tar.gz:
Publisher:
release.yml on Blhota/arabic-pdf2ebook
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arabic_pdf2ebook-0.1.3.tar.gz -
Subject digest:
1b4bc8d18ef8db4c0085614de9fe73d42e8361ee35b89f93b3f8532b86b360cc - Sigstore transparency entry: 1802754115
- Sigstore integration time:
-
Permalink:
Blhota/arabic-pdf2ebook@dc873c6aa8766bb4342384bea2c991ebdd93e7ef -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/Blhota
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dc873c6aa8766bb4342384bea2c991ebdd93e7ef -
Trigger Event:
push
-
Statement type:
File details
Details for the file arabic_pdf2ebook-0.1.3-py3-none-any.whl.
File metadata
- Download URL: arabic_pdf2ebook-0.1.3-py3-none-any.whl
- Upload date:
- Size: 408.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c0ece6d517e9b35bb26474dbb7fb5c548067bd3e639b94a2ef422846c4e4074
|
|
| MD5 |
2a4ba5e91c782098377734632099401a
|
|
| BLAKE2b-256 |
8d591c52a9fd5977d5ba22e06b47c1250e6830e650a6176f96865670e9c39547
|
Provenance
The following attestation bundles were made for arabic_pdf2ebook-0.1.3-py3-none-any.whl:
Publisher:
release.yml on Blhota/arabic-pdf2ebook
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arabic_pdf2ebook-0.1.3-py3-none-any.whl -
Subject digest:
8c0ece6d517e9b35bb26474dbb7fb5c548067bd3e639b94a2ef422846c4e4074 - Sigstore transparency entry: 1802754401
- Sigstore integration time:
-
Permalink:
Blhota/arabic-pdf2ebook@dc873c6aa8766bb4342384bea2c991ebdd93e7ef -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/Blhota
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dc873c6aa8766bb4342384bea2c991ebdd93e7ef -
Trigger Event:
push
-
Statement type: