Tools,

Tamil PDF to Word, tested

693 of 693

words right on 2 of 3 PDFs: the script

Get the free script

Whole words right, 3 typed PDFs

Way Chromium Libre­Office reportlab
LibreOffice Writer 2.3% 0.1% 2.3%
pdf2docx 85.9% 80.4% 2.2%
pdftotext 100.0% 100.0% 2.3%
Tesseract: tam 49.9% 49.9% 49.8%
Tesseract: tam, U+200C deleted 99.9% 99.6% 99.3%
Tesseract: Tamil best, U+200C deleted 99.6% 98.8% 99.3%
The script on this page 100.0% 100.0% 99.3%

Why converters break Tamil

The script: text first, OCR if broken

It copies each page's text, and sends a broken page to Tesseract tam: no Tamil text, private codes, NUL characters, or 3 or more signs that follow no letter.

python3 tamil_pdf_to_word.py in.pdf out.docx
tamil_pdf_to_word.py, the whole script
"""Tamil PDF to Word: an editable .docx. The script of brasspage.com/tamil-pdf-to-word/

Needs on your PATH: Poppler (pdftotext, pdftoppm), Tesseract with the tam model, and pandoc. Python 3, stdlib only.
python3 tamil_pdf_to_word.py in.pdf out.docx [tesseract language, default tam]

Each page: the PDF's own text (pdftotext). A page whose own text is broken is read by Tesseract (300 dpi) instead.
Broken: fewer than 20 Tamil letters (a scan, or an old font such as Bamini that stores Latin codes), Private Use
Area characters, NUL characters, or 3 or more vowel signs or pulli that do not follow a consonant (the signs that
draw before a letter, such as the e sign, were stored in the wrong order). Tesseract writes a zero width non-joiner
(U+200C) after the pulli; the script deletes it, so a search in Word finds the word. Blank lines split paragraphs.
pandoc writes the .docx in Tamil (ta-IN), and set_tamil() marks it Tamil for complex script too (ta-IN, not
pandoc's ar-SA). Each page's choice goes to stderr.
"""

import html
import re
import subprocess
import sys
import unicodedata
import zipfile

TAMIL = re.compile("[\u0b82-\u0bcd\u0bd7]")  # Tamil letters and signs
ORPHAN = re.compile("(?<![\u0b95-\u0bb9])[\u0bbe-\u0bcd\u0bd7]")  # a sign that does not follow a consonant


def broken(text):
    """Why a page's own text is broken, or None if it looks right."""
    t = unicodedata.normalize("NFC", text).translate({0x200C: None, 0x200D: None})
    if len(TAMIL.findall(t)) < 20:  # ponytail: an English-only page goes to OCR too
        return "no Tamil text"
    if re.search("[\ue000-\uf8ff]", t):
        return "Private Use Area characters"
    if "\x00" in t:
        return "NUL characters"
    if len(ORPHAN.findall(t)) >= 3:  # one stray sign is a typing slip, not a broken page
        return "vowel signs or pulli not after a letter"
    return None


def ocr(pdf, n, lang):
    page = ["pdftoppm", "-r", "300", "-gray", "-png", "-f", str(n), "-l", str(n), pdf]
    png = subprocess.run(page, capture_output=True, check=True).stdout
    cmd = ["tesseract", "-", "-", "-l", lang, "--dpi", "300"]
    return subprocess.run(cmd, input=png, capture_output=True, check=True).stdout.decode().replace("\u200c", "")


def paragraphs(text):
    return [" ".join(b.split()) for b in re.split(r"\n\s*\n", text) if b.strip()]


def pdf_to_docx(pdf, docx, lang="tam"):
    out = subprocess.run(["pdftotext", "-enc", "UTF-8", pdf, "-"], capture_output=True, check=True).stdout.decode()
    paras = []
    for n, text in enumerate(out.split("\f")[:-1], 1):  # pdftotext ends every page with a form feed
        why = broken(text)
        print(f"page {n}: " + (f"OCR ({why})" if why else "text layer"), file=sys.stderr)
        paras += paragraphs(ocr(pdf, n, lang) if why else text)  # ponytail: a paragraph across a page break stays two
    body = "".join(f"<p>{html.escape(p)}</p>\n" for p in paras)
    subprocess.run(["pandoc", "-f", "html", "-o", docx, "-M", "lang=ta-IN"], input=body.encode(), check=True)
    set_tamil(docx)


def set_tamil(docx):
    """pandoc's styles keep Arabic as the complex-script language (w:bidi="ar-SA"). Make it Tamil."""
    with zipfile.ZipFile(docx) as z:
        parts = [(info, z.read(info)) for info in z.infolist()]
    with zipfile.ZipFile(docx, "w") as z:
        for info, data in parts:
            if info.filename == "word/styles.xml":
                data = data.replace(b'w:bidi="ar-SA"', b'w:bidi="ta-IN"')
            z.writestr(info, data)


if __name__ == "__main__":
    pdf_to_docx(*sys.argv[1:4])

Bamini to Unicode, offline

Bamini fonts draw Tamil on Latin codes. I had no Bamini file, so two free tools wrote codes for our 693 words: Open-Tamil 1.1 and aril 0.1.1.

Words back, of 693
Codes by Open-Tamil reads aril reads
Open-Tamil 638 638
aril 675 691
aril -f bamini < codes.txt > tamil.txt

A look-alike Bamini PDF: aril reads it

My look-alike Bamini PDF drew aril's codes in DejaVu Sans: I found no Bamini font with a license.

aril read it back: 690 of 693 words. pdftotext, then Open-Tamil: 674.

aril -f bamini in.pdf -o out.txt
pandoc -f markdown out.txt -o out.docx -M lang=ta

The script sends such a page to OCR. On a real Bamini PDF, OCR sees the Tamil it draws. I could not test that: my look-alike draws Latin letters.

Our Actor: no install, no Tamil yet

Our Apify Actor, PDF to Markdown OCR, turns PDFs into Markdown in one call. It reads 23 languages, not Tamil yet.

What I tested, and what I did not

How I tested
  • Text: 12 passages from proofread ta.wikisource pages (public domain or CC0), one a page. I quote none of them.
  • They hold 693 words, 896 pulli and 123 ை signs.
  • One word ends in a stray ே after a pulli. OCR did not write it, so OCR can reach 692 of 693 words, and a text layer 693.
  • PDFs in Noto Sans Tamil 2.004: Chromium 153 print to PDF and LibreOffice 26.8.1.1 export, both with lang ta, and reportlab 5.1.2 with shaping on.
  • Ways: LibreOffice Writer (soffice --infilter=writer_pdf_import), pdf2docx 0.5.13 with PyMuPDF 2.2, pdftotext from Poppler 26.03.0, Tesseract 5.5.4 at 300 dpi with tessdata_fast tam and tessdata_best script/Tamil 4.1.0, pandoc 3.13.
  • Words right: truth words found whole in the .docx text, each word counted as often as it appears. A U+200C makes a word count as wrong. Text from pdftotext and Tesseract went to pandoc for the .docx.
  • I scored the text inside each .docx. LibreOffice on this Mac drew no Tamil when it printed the 4 from the Chromium PDF, so I did not check how they look.
  • Bamini: Open-Tamil 1.1 (PyPI; only its txt2unicode folder) and aril-cli 0.1.1 (crates.io, built from source with its lock file). Both ran offline.
  • The look-alike PDF: aril's codes drawn by reportlab in DejaVu Sans, so it copies like a Bamini PDF but does not look like one.
  • Our Actor has no Tamil model, so it was not in this test.
Sources
  • pdf2docx is MIT. It needs PyMuPDF, which is AGPL-3.0 or a paid license.
  • Open-Tamil on PyPI: MIT in its metadata, but its txt2unicode converter files carry a GPL-3.0-or-later header.
  • aril-cli on crates.io: MIT or Apache-2.0.
  • tessdata_best and tessdata_fast for Tesseract (Apache-2.0).
  • Font: Noto Sans Tamil, OFL.
  • Scripts and results stay in our private repo, in research/bench/tamil-pdf-to-word-2026-11-28/.
  • We make the Apify Actor, not these tools.

Questions people ask

How do I convert a Tamil PDF to Word for free?

Copy the PDF's own text where it is good, OCR the pages where it is broken with Tesseract tam, delete the U+200C it adds, then let pandoc write the .docx. The free script on this page did that on 3 typed PDFs: 99.3% to 100.0% of words right.

How do I convert Bamini to Unicode?

aril 0.1.1 read back the Bamini codes it wrote, offline: 691 of 693 words from text, 690 from a look-alike PDF. Open-Tamil 1.1 read those codes at 675. On Open-Tamil's codes, both read 638. I had no real Bamini file, only codes the two tools wrote.

Why does Tamil text from a PDF come out scrambled?

Some converters put Tamil signs and letters out of order: LibreOffice Writer got 0.1% to 2.3% of words right. Some PDFs keep private glyph codes in place of some letters, and then no copy works: OCR the page. pdftotext kept 100% on 2 of our 3 PDFs.