Tools,

Marathi PDF to Word, tested

121 of 121

short i signs kept, each PDF: the script

PDF to text in one call, no install

Whole words right, 3 typed PDFs

Way Chromium Libre­Office reportlab
LibreOffice Writer 50.0% 4.6% 53.1%
pdf2docx 90.5% 99.6% 52.9%
pdftotext 97.9% 97.9% 57.9%
Tesseract: mar 96.5% 97.1% 98.8%
Tesseract: mar best 98.4% not run not run
Tesseract: hin 92.7% 92.9% 93.2%
Our Actor (hin) 92.4% 91.9% 93.4%
The script on this page 97.9% 97.9% 98.8%

Why converters break Marathi

Noto's Marathi श trips the fast mar

Chromium and LibreOffice drew Noto's Marathi श (lang mr); reportlab drew the Hindi one.

Words with श right, of 34
Model Chromium Libre­Office reportlab
mar (fast) 19 23 34
mar best 32 not run not run

The script: text first, OCR if broken

It copies each page's text, and sends a broken page to Tesseract mar: no text, private codes, a word that starts with a sign, or 200+ Devanagari letters with no ि.

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

Needs on your PATH: Poppler (pdftotext, pdftoppm), Tesseract with the mar model, and pandoc. Python 3, stdlib only.
python3 marathi_pdf_to_word.py in.pdf out.docx

Each page: the PDF's own text (pdftotext). A page whose own text is broken is read by Tesseract (300 dpi, mar)
instead. Broken: no text (a scan), Private Use Area characters (half letters a font kept to itself), NUL characters,
a word that starts with a vowel sign or halant, or 200 or more Marathi letters with no short i sign (ि). Blank lines
split paragraphs. pandoc writes the .docx in Marathi (mr-IN), and set_marathi() marks it Marathi for complex script
too (mr-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

LETTER = "ऀ-ॣॱ-ॿ"  # Devanagari letters and signs
SIGN_FIRST = re.compile(f"(?<![{LETTER}])[ऀ-ःऺ-ॏ]")


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(re.findall(r"\w", t)) < 20:
        return "no text"
    if re.search("[\ue000-\uf8ff]", t):
        return "Private Use Area characters"
    if "\x00" in t:
        return "NUL characters"
    if SIGN_FIRST.search(t):
        return "a word starts with a vowel sign or halant"
    if len(re.findall(f"[{LETTER}]", t)) >= 200 and "ि" not in t:
        return "no short i sign"
    return None


def ocr(pdf, n):
    page = ["pdftoppm", "-r", "300", "-gray", "-png", "-f", str(n), "-l", str(n), pdf]
    png = subprocess.run(page, capture_output=True, check=True).stdout
    # mar, not hin: hin has no ळ, ऱ or ॅ in its character set. mar's config blacklists nothing (hin's blacklists 1).
    cmd = ["tesseract", "-", "-", "-l", "mar", "--dpi", "300"]
    return subprocess.run(cmd, input=png, capture_output=True, check=True).stdout.decode()


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):
    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) 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=mr-IN"], input=body.encode(), check=True)
    set_marathi(docx)


def set_marathi(docx):
    """pandoc's styles keep Arabic as the complex-script language (w:bidi="ar-SA"). Make it Marathi."""
    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="mr-IN"')
            z.writestr(info, data)


if __name__ == "__main__":
    pdf_to_docx(sys.argv[1], sys.argv[2])

Shree Lipi to Unicode, offline

Shree Lipi fonts draw Marathi from Latin codes. In Shree 0708, unicode-bunny writes प्रमाणभाषा ही एक बोली भाषाच असते. as à_mU^mfm hr EH$ ~mobr ^mfmM AgVo.

Read by legacylipi Words back, of 944
As unicode-bunny wrote them 836
With ि moved before its letter 934

A Shree Lipi PDF: OCR the page

My look-alike Shree Lipi PDF drew its codes in DejaVu Sans: I found no Shree font with a license.

Our Actor and the script kept the codes on all 12 pages: neither puts OCR text in place of a code layer on its own today. The fix: OCR the page image with mar.

pdftoppm -r 300 -gray -png in.pdf p
for f in p-*.png; do tesseract "$f" - -l mar; echo; done > out.txt
pandoc -f markdown out.txt -o out.docx -M lang=mr

Our Actor: no install, but no mar

Our Apify Actor, PDF to Markdown OCR, has hin but no mar today, so it shares hin's gaps.

The API call, then pandoc
curl -s -X POST "https://api.apify.com/v2/acts/brasspage~pdf-ocr-to-markdown/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"documentUrls": ["https://example.com/your-file.pdf"], "language": "hin"}' \
  | jq -r '.[].markdown' > out.md
pandoc out.md -o out.docx -M lang=mr

What I tested, and what I did not

How I tested
  • Text: 12 passages from proofread mr.wikisource pages (public domain or CC BY-SA 4.0), one a page. I quote none of them.
  • They hold 944 words, 121 short i signs and 34 ळ.
  • 8 words carry a doubled anusvara that draws as one dot.
  • So OCR can reach 936 of 944 words, and a text layer 944.
  • PDFs in Noto Sans Devanagari: Chromium 153 print to PDF and LibreOffice 26.8.1.1 export, both with lang mr, 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 mar and hin 4.1.0 (mar best from tessdata_best; hin's digit 1 blacklist cleared), pandoc 3.13. I opened 4 of the .docx files in LibreOffice to look at them.
  • Words right: truth words found whole in the .docx text, each word counted as often as it appears. Text from pdftotext, Tesseract and the Actor went to pandoc for the .docx.
  • These Marathi passages had fewer short i signs than our Hindi ones, so a good page of 200 or more letters with none goes to OCR: slower, and then read by mar.
  • Our Actor: its page code (last changed in commit 92ac8be8), run on this Mac, not on Apify. Language hin, Markdown out, then pandoc. It read all 36 test pages by OCR.
  • Shree Lipi: unicode-bunny 1.0.2 (npm) wrote Shree 0708 codes for the same passages, and legacylipi 1.0.2 read them back. I ran only legacylipi's converter code from its wheel: the package lists 14 dependencies, PyMuPDF and EasyOCR among them.
  • unicode-bunny's cli.js stops with a TypeError; its library call works. It writes श्र with the code of ब, and द्र with the code of त्र: 1 word each here. The Shree sample in legacylipi's README shares no code with Shree 0708: Shree Lipi is more than one code layout.
  • The look-alike PDF: the codes drawn by reportlab in DejaVu Sans, so it copies like a Shree Lipi PDF but does not look like one. The OCR stand-in: the Chromium PDF of the same passages.
Sources
  • pdf2docx is MIT. It needs PyMuPDF, which is AGPL-3.0 or a paid license.
  • unicode-bunny on npm: MIT in its package.json and README, with no license file.
  • legacylipi on PyPI: MIT in its metadata, with no MIT license text.
  • tessdata_best and tessdata_fast mar and hin for Tesseract (Apache-2.0).
  • Font: Noto Sans Devanagari, OFL.
  • Scripts and results stay in our private repo, in research/bench/marathi-pdf-to-word-2026-11-28/.
  • We make the Apify Actor, not these tools.

Questions people ask

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

Copy the PDF's own text where it is good, OCR the pages where it is broken with Tesseract mar, then let pandoc write the .docx. The free script on this page did that on 3 typed PDFs: 97.9% to 98.8% of words right.

How do I convert Shree Lipi to Unicode?

For Shree Lipi codes as text, legacylipi's shree-dev table read our Shree 0708 codes back: 934 of 944 words after we moved ि before its letter, 836 as unicode-bunny wrote them. For a PDF, OCR the page image with mar instead.

Why does Shree Lipi copy as English letters?

A Shree Lipi font draws Marathi shapes on Latin codes, so a copy gives you the codes. OCR of the page image reads the shapes and writes Unicode Marathi. I measured OCR on a Noto Sans page of the same text, not on a real Shree Lipi page.