Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

pdf2md

Python Platform GUI OCR PDF

  • A Windows tool for converting documents (PDF · Word .docx · Markdown, scanned files included) between formats.
    • Input: .pdf, .docx, .md → Output: .md, .docx, .pdf
  • Built as preprocessing for vector-embedding in RAG pipelines.
  • Packaged as a GUI so non-developers can use it.

Demo

pdf2md_1_compressed.mp4

Features

  • Multi-format conversion — pick the output format (Markdown / Word / PDF) from the Convert to: dropdown at the top.
    • Items whose input and output formats match are copied as-is (e.g. .docx → .docx).
    • PDF output automatically embeds a system font (Malgun Gothic) so Korean and other CJK characters don't break.
  • Queue individual files or whole folders (including subfolders) and convert them sequentially.
  • OCR for scanned PDFs — Korean, Japanese, Latin scripts, and more.
  • Live display of per-page and overall progress, elapsed time, estimated completion time, and pages per second.
  • Runs on a background thread — minimize the window and keep working on other things.
  • "Open output folder" button, plus a per-item right-click menu of file actions.
  • All status is written to the in-app log — no popup dialogs to interrupt your workflow.
  • Markdown splitting — automatically split a large .md file into a chosen number of chunks (to work around upload size limits on vector-embedding services).

Quick install (Windows)

git clone <this-repo>
cd pdf2md
.\setup.bat
  • setup.bat installs the Python packages automatically.
  • If Tesseract OCR is not installed, it downloads the installer and kor.traineddata, then runs them.
  • Because Tesseract installs into Program Files, a UAC administrator prompt will appear.

If you only need English or Chinese OCR, you can skip Tesseract — pip install -r requirements.txt alone installs RapidOCR, which handles those languages.

Manual install

  1. Install Python 3.10 or newer from https://www.python.org/.
  2. Run pip install -r requirements.txt.
  3. (For Korean / Japanese / Cyrillic / Arabic, etc.) Install Tesseract from https://github.com/UB-Mannheim/tesseract/wiki, checking the language data you need during setup.
    • On startup the GUI auto-detects Tesseract at C:\Program Files\Tesseract-OCR\ — no environment variables to configure.

Run

Double-click pdf2md.bat, or run the command below.

python pdf2md_gui.py

How it works

  • Markdown is used as the hub format — every input is converted to Markdown first, then written out in the selected output format.
    • PDF → Markdown: native text extraction via pymupdf4llm.
    • DOCX → Markdown: mammoth (semantic HTML conversion) + markdownify.
    • Markdown → DOCX: markdown (→ HTML) + htmldocx (→ Word).
    • Markdown → PDF: rendered with the PyMuPDF Story HTML engine (CJK font embedded, then subset to minimize file size).
    • When the input and output formats are identical, the original is copied as-is with no round-trip (avoiding any loss of formatting).
  • For scanned files, if Tesseract is installed it runs pure Tesseract OCR — handling every writing system covered by the installed traineddata.
  • If Tesseract is not installed, it falls back to RapidOCR (English and Chinese only).
  • Output panel: choose the output format; by default it saves next to the source file, or to a folder you specify.
  • OCR panel: toggles for auto-OCR / force-OCR and an OCR-language dropdown (default kor+eng, applied to PDF inputs only).

Markdown splitting

  • Click the Split Markdown... button in the top toolbar to open the split dialog.
  • Specify an input .md file and a chunk count (N) → produces N files named filename_part01.md, filename_part02.md, ….
  • Splits only at paragraph (blank-line) boundaries — paragraphs, lists, code blocks, and tables are never cut in the middle.
  • Each chunk is distributed as evenly as possible — to avoid exceeding an embedding model's input limit.
  • Example use: when a vector-embedding service (e.g. Google Vertex AI) hits its single-file size limit, split the same markdown into several chunks and upload them.

Notes

  • The default language is kor+eng — pick another from the OCR-language dropdown (Japanese, Chinese, German, etc.).
  • Some presets stack multiple languages with the + symbol (e.g. kor+eng); the matching Tesseract traineddata must be installed for each code.
  • The first Korean conversion may be slightly slow due to Tesseract warm-up — subsequent pages run at roughly 0.5–2 seconds per page on a recent CPU.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages