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).

🚀 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.1.tar.gz (268.1 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.1-py3-none-any.whl (272.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: arabic_pdf2ebook-0.1.1.tar.gz
  • Upload date:
  • Size: 268.1 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.1.tar.gz
Algorithm Hash digest
SHA256 5592b84e9ac18febf4232493c7c313939309ec05c1d1c9f0df172436be6bc38f
MD5 fe1350beeb489a59525ba9511e1dd5a6
BLAKE2b-256 047fbe7f86d8caf2199038980c3522aab256e4e52f8280983dabfac9f1fa217b

See more details on using hashes here.

Provenance

The following attestation bundles were made for arabic_pdf2ebook-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for arabic_pdf2ebook-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dd71c99289c2a6b3e04437fc7327ffefa13fafdd41442d4426dddde6cbc68727
MD5 5cb84787d055ce0aa5fbb151338ca2fe
BLAKE2b-256 635194eb9755567846dbfb9c40759e155ae20f37a2e4e07218fd4e72a3dc0c8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for arabic_pdf2ebook-0.1.1-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