qalam
Correct, logical-order Arabic text extraction from digitally-born PDFs — without OCR.
Most PDF extractors hand back Arabic that is reversed, made of presentation forms, or
silently corrupted at every ligature. qalam fixes the reading order, folds the shaped
glyphs back to base letters, reconstructs multi-column reading order, and — when a page
has no usable text layer — says so instead of returning plausible-looking garbage.
import qalam
text = qalam.extract_text("guide.pdf")
doc = qalam.Document("guide.pdf")
print(doc.confidence) # 0.91
print(doc.pages_needing_ocr) # [2, 3, 42, 43]
for page in doc:
if page.needs_ocr:
print(page.number, page.reasons)
else:
print(page.text)
Document.text omits pages that need OCR, so a scanned page never masquerades as a
result. Read page.text directly if you want to see it anyway.
Structure, not just a string
A page is an ordered list of typed blocks. Each carries a kind, so you can branch on it
without reaching for isinstance.
for block in doc.page(6).blocks:
if block.kind == "table":
for row in block.to_rows(): # the shape csv.writer wants
print(row)
elif block.kind == "image":
block.save(block.file_name)
else:
print(block.text)
page.tables, page.images and page.lines are filtered views over the same blocks.
Tables know their reading order: on an Arabic page rows[0][0] is the rightmost cell,
where a reader starts.
t = doc.page(5).tables[0]
t.row_count, t.column_count, t.confidence
t.rows[1][0].text # 'المحافظات'
Images come back decoded — JPEG passed through untouched, everything else re-encoded as
PNG — or with an unsupported_reason saying why not. Never silently dropped.
Each line carries its geometry and styling — line.direction, line.size, line.color,
line.confidence — enough to rebuild a styled document.
page.tagged says whether the reading order came from the document's own structure tree
rather than from geometry.
HTML output
open("out.html", "w").write(doc.to_html())
Reading order, headings inferred from type size, colour, tables with dir="rtl", images
inlined. doc.heading_sizes() reports what the heading inference assumed.
For Markdown, convert the HTML with turndown or pandoc — Markdown cannot state text
direction, so an Arabic table comes out mirrored.
Built on a Rust core; the GIL is released during extraction and rendering.
Metadata
Release files for qalam 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qalam-0.1.3.tar.gz | 240.1 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| qalam-0.1.3-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| qalam-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| qalam-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| qalam-0.1.3-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| qalam-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 5.7 MB
Release files / qalam-0.1.3.tar.gz
| Download URL | qalam-0.1.3.tar.gz |
|---|---|
| Size | 240.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab8bd99fd7d411c775279fe39fbfcfe827f289f12042587d9c069f7a6501d432
|
|
BLAKE2b-256 checksum How to use checksums |
d13cdd28352567f4ca646ec3cc3df156d0beaa7725be1d2903957355dc27ad52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency logRelease files / qalam-0.1.3-cp39-abi3-win_amd64.whl
| Download URL | qalam-0.1.3-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 962.1 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ebf5e80372e2692ef3b5597d916d486234af3e9fa2ab552e58bee50b2a453abc
|
|
BLAKE2b-256 checksum How to use checksums |
6df31ad0baa4d0595bde5b89f11a7a3494cd1177b3f51342b27c9907195d8d03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency logRelease files / qalam-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | qalam-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
82a93afd219aaddb76c3214dd0301394de18047ef5a69c0cfa87953ac31db9a0
|
|
BLAKE2b-256 checksum How to use checksums |
d710177885d463e020cc5ebf063b6a60839c9e9f0d7f7180a4318070bb645759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency logRelease files / qalam-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | qalam-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
becfb9ad34c5bd94d8d77f162e20ee11290fc09a6324d783fa159c55b7f9dc72
|
|
BLAKE2b-256 checksum How to use checksums |
166bc1b23ac1e6cf158a117a9d5e2b2daa1259f59c7676a5a35557134ed78077
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency logRelease files / qalam-0.1.3-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | qalam-0.1.3-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2230513b4b949224e0582e1e005488508ef69a16b6282109237dee5760eb85b2
|
|
BLAKE2b-256 checksum How to use checksums |
6d189974fbaf9257216059d936d8e706c1c2eb761b757650d210257dac0edc8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency logRelease files / qalam-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | qalam-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
03817de06ff1ca07c481a5d3b93437311a69f242732457f265fce02fbe39951d
|
|
BLAKE2b-256 checksum How to use checksums |
1268ba66ebdc0a8efaa46e198cc532263bb69af0f7cb35d2e4edb71eae944597
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency log