Skip to main content

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
scanned page EPUB text web UI

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 pagepdf2ebook ui opens a friendly bilingual drag-and-drop page in your browser. Everything still runs on your own computer.
  • Wi-Fi sendpdf2ebook send book.epub uploads 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), and pdf2ebook fonts export writes 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:

  1. tessdata_best Arabic model + LSTM engine
  2. preprocessing tuned for old paper: Sauvola adaptive binarization, CLAHE contrast, denoising, deskew, margin removal, upscaling of small print
  3. a rescue pass that re-OCRs low-confidence pages with an alternate binarization
  4. 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

arabic_pdf2ebook-0.1.2.tar.gz (402.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arabic_pdf2ebook-0.1.2-py3-none-any.whl (407.6 kB view details)

Uploaded Python 3

File details

Details for the file arabic_pdf2ebook-0.1.2.tar.gz.

File metadata

  • Download URL: arabic_pdf2ebook-0.1.2.tar.gz
  • Upload date:
  • Size: 402.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arabic_pdf2ebook-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1bf91731253973d72478c74ec47578de726aa280b91d8ad2aba6fa6e24809be6
MD5 654b72f500a32dd8ebc7544ea97b6ded
BLAKE2b-256 a68134547ddc1af848ae24f20af3b252b1f71bc25fe73a0bbc228e918b8f0a68

See more details on using hashes here.

Provenance

The following attestation bundles were made for arabic_pdf2ebook-0.1.2.tar.gz:

Publisher: release.yml on Blhota/arabic-pdf2ebook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arabic_pdf2ebook-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for arabic_pdf2ebook-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 14d8f1cbb9659b4fce9353dc196764faa88e6e1a958a92257eb6b2e1e34b7c96
MD5 7d724b48831113d1ad8e7d845d7a1f08
BLAKE2b-256 b9fd8ec4ce07ab1f8ca9e8d3f7bf7f53a16f2e4684cfd0f44410d0df7737e817

See more details on using hashes here.

Provenance

The following attestation bundles were made for arabic_pdf2ebook-0.1.2-py3-none-any.whl:

Publisher: release.yml on Blhota/arabic-pdf2ebook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page