document-to-markdown 0.6.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- document_to_markdown-0.6.1/LICENSE +45 -0
- document_to_markdown-0.6.1/PKG-INFO +329 -0
- document_to_markdown-0.6.1/README.md +234 -0
- document_to_markdown-0.6.1/document_converter/__init__.py +7 -0
- document_to_markdown-0.6.1/document_converter/__main__.py +6 -0
- document_to_markdown-0.6.1/document_converter/cli.py +182 -0
- document_to_markdown-0.6.1/document_converter/csv_adapter.py +67 -0
- document_to_markdown-0.6.1/document_converter/docx_adapter.py +435 -0
- document_to_markdown-0.6.1/document_converter/email_adapter.py +308 -0
- document_to_markdown-0.6.1/document_converter/excel_adapter.py +396 -0
- document_to_markdown-0.6.1/document_converter/html_adapter.py +413 -0
- document_to_markdown-0.6.1/document_converter/image_adapter.py +161 -0
- document_to_markdown-0.6.1/document_converter/markdown.py +129 -0
- document_to_markdown-0.6.1/document_converter/models.py +36 -0
- document_to_markdown-0.6.1/document_converter/ocr_engine.py +1129 -0
- document_to_markdown-0.6.1/document_converter/pdf_adapter.py +622 -0
- document_to_markdown-0.6.1/document_converter/pipeline.py +137 -0
- document_to_markdown-0.6.1/document_converter/pptx_adapter.py +347 -0
- document_to_markdown-0.6.1/document_to_markdown.egg-info/PKG-INFO +329 -0
- document_to_markdown-0.6.1/document_to_markdown.egg-info/SOURCES.txt +25 -0
- document_to_markdown-0.6.1/document_to_markdown.egg-info/dependency_links.txt +1 -0
- document_to_markdown-0.6.1/document_to_markdown.egg-info/entry_points.txt +2 -0
- document_to_markdown-0.6.1/document_to_markdown.egg-info/requires.txt +31 -0
- document_to_markdown-0.6.1/document_to_markdown.egg-info/top_level.txt +1 -0
- document_to_markdown-0.6.1/pyproject.toml +85 -0
- document_to_markdown-0.6.1/setup.cfg +4 -0
- document_to_markdown-0.6.1/tests/test_converter.py +1087 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
MIT License (with Commons Clause License Condition v1.0)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hotroso
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
================================================================================
|
|
24
|
+
|
|
25
|
+
“Commons Clause” License Condition v1.0
|
|
26
|
+
|
|
27
|
+
The Software is provided to you by the Licensor under the License, as defined
|
|
28
|
+
below, subject to the following condition.
|
|
29
|
+
|
|
30
|
+
Without limiting other conditions in the License, the grant of rights under the
|
|
31
|
+
License will not include, and the License does not grant to you, the right to
|
|
32
|
+
Sell the Software.
|
|
33
|
+
|
|
34
|
+
For purposes of the foregoing, “Sell” means practicing any or all of the rights
|
|
35
|
+
granted to you under the License to provide to third parties, for a fee or other
|
|
36
|
+
consideration (including without limitation fees for hosting or consulting/
|
|
37
|
+
support services related to the Software), a product or service whose value
|
|
38
|
+
derives, entirely or substantially, from the functionality of the Software.
|
|
39
|
+
|
|
40
|
+
Any license notice or attribution required by the License must also include this
|
|
41
|
+
Commons Clause License Condition notice.
|
|
42
|
+
|
|
43
|
+
Software: document-to-markdown.
|
|
44
|
+
License: MIT License.
|
|
45
|
+
Licensor: hotroso.
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: document-to-markdown
|
|
3
|
+
Version: 0.6.1
|
|
4
|
+
Summary: 100% local PDF, Office (DOCX, PPTX, Excel), Email, HTML, CSV, and image to AI-friendly Markdown converter
|
|
5
|
+
License: MIT License (with Commons Clause License Condition v1.0)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 hotroso
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
================================================================================
|
|
28
|
+
|
|
29
|
+
“Commons Clause” License Condition v1.0
|
|
30
|
+
|
|
31
|
+
The Software is provided to you by the Licensor under the License, as defined
|
|
32
|
+
below, subject to the following condition.
|
|
33
|
+
|
|
34
|
+
Without limiting other conditions in the License, the grant of rights under the
|
|
35
|
+
License will not include, and the License does not grant to you, the right to
|
|
36
|
+
Sell the Software.
|
|
37
|
+
|
|
38
|
+
For purposes of the foregoing, “Sell” means practicing any or all of the rights
|
|
39
|
+
granted to you under the License to provide to third parties, for a fee or other
|
|
40
|
+
consideration (including without limitation fees for hosting or consulting/
|
|
41
|
+
support services related to the Software), a product or service whose value
|
|
42
|
+
derives, entirely or substantially, from the functionality of the Software.
|
|
43
|
+
|
|
44
|
+
Any license notice or attribution required by the License must also include this
|
|
45
|
+
Commons Clause License Condition notice.
|
|
46
|
+
|
|
47
|
+
Software: document-to-markdown.
|
|
48
|
+
License: MIT License.
|
|
49
|
+
Licensor: hotroso.
|
|
50
|
+
|
|
51
|
+
Project-URL: Homepage, https://github.com/hotroso/document-to-markdown
|
|
52
|
+
Project-URL: Repository, https://github.com/hotroso/document-to-markdown
|
|
53
|
+
Project-URL: Issues, https://github.com/hotroso/document-to-markdown/issues
|
|
54
|
+
Keywords: pdf,docx,pptx,excel,email,outlook,markdown,ocr,paddleocr,tesseract,rag,llm,document-converter
|
|
55
|
+
Classifier: Development Status :: 4 - Beta
|
|
56
|
+
Classifier: Environment :: Console
|
|
57
|
+
Classifier: Intended Audience :: Developers
|
|
58
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
59
|
+
Classifier: License :: Other/Proprietary License
|
|
60
|
+
Classifier: Programming Language :: Python :: 3
|
|
61
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
62
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
63
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
64
|
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
65
|
+
Classifier: Topic :: Utilities
|
|
66
|
+
Requires-Python: >=3.10
|
|
67
|
+
Description-Content-Type: text/markdown
|
|
68
|
+
License-File: LICENSE
|
|
69
|
+
Requires-Dist: pdfplumber>=0.11.0
|
|
70
|
+
Requires-Dist: pypdfium2>=4.25.0
|
|
71
|
+
Requires-Dist: openpyxl>=3.1.5
|
|
72
|
+
Provides-Extra: ocr
|
|
73
|
+
Requires-Dist: paddlepaddle>=2.6.0; extra == "ocr"
|
|
74
|
+
Requires-Dist: paddleocr>=2.7.0; extra == "ocr"
|
|
75
|
+
Requires-Dist: Pillow>=10.0.0; extra == "ocr"
|
|
76
|
+
Requires-Dist: numpy>=1.24.0; extra == "ocr"
|
|
77
|
+
Provides-Extra: tesseract
|
|
78
|
+
Requires-Dist: pytesseract>=0.3.10; extra == "tesseract"
|
|
79
|
+
Requires-Dist: Pillow>=10.0.0; extra == "tesseract"
|
|
80
|
+
Provides-Extra: excel-calc
|
|
81
|
+
Requires-Dist: xlcalculator>=0.5.0; extra == "excel-calc"
|
|
82
|
+
Provides-Extra: outlook
|
|
83
|
+
Requires-Dist: olefile>=0.47; extra == "outlook"
|
|
84
|
+
Provides-Extra: all
|
|
85
|
+
Requires-Dist: paddlepaddle>=2.6.0; extra == "all"
|
|
86
|
+
Requires-Dist: paddleocr>=2.7.0; extra == "all"
|
|
87
|
+
Requires-Dist: pytesseract>=0.3.10; extra == "all"
|
|
88
|
+
Requires-Dist: Pillow>=10.0.0; extra == "all"
|
|
89
|
+
Requires-Dist: numpy>=1.24.0; extra == "all"
|
|
90
|
+
Requires-Dist: xlcalculator>=0.5.0; extra == "all"
|
|
91
|
+
Requires-Dist: olefile>=0.47; extra == "all"
|
|
92
|
+
Provides-Extra: dev
|
|
93
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
94
|
+
Dynamic: license-file
|
|
95
|
+
|
|
96
|
+
# Document to Markdown
|
|
97
|
+
|
|
98
|
+
[](https://github.com/hotroso/document-to-markdown/actions/workflows/ci.yml)
|
|
99
|
+
[](https://github.com/hotroso/document-to-markdown/releases)
|
|
100
|
+
[](https://github.com/hotroso/document-to-markdown/releases)
|
|
101
|
+
[](pyproject.toml)
|
|
102
|
+
[](LICENSE)
|
|
103
|
+
[](https://github.com/hotroso/document-to-markdown/stargazers)
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
Local, zero-config converter for **PDF**, **Office (DOCX, PPTX, Excel)**, **Email (EML/Outlook MSG)**, **HTML**, **CSV/TSV**, and **images** into clean, AI/RAG-ready **Markdown**.
|
|
108
|
+
|
|
109
|
+
Designed for personal and enterprise AI, LLM, and RAG workflows where document layouts vary wildly and you want clean `.md` files out of the box without complex setup or cloud APIs.
|
|
110
|
+
|
|
111
|
+
## Highlights
|
|
112
|
+
|
|
113
|
+
- **Clean Markdown by default**: Outputs only the `.md` file by default. Extracted image/attachment folders (`_assets`) and JSON metadata sidecars (`.meta.json`) are opt-in via `--assets` and `--meta`.
|
|
114
|
+
- **Broad local document support out of the box**: Zero extra dependencies for **Word (`.docx`)**, **PowerPoint (`.pptx` with speaker notes)**, **Email (`.eml`)**, **HTML**, and **CSV/TSV**, plus **PDF**, **Excel (`.xlsx`/`.xlsm`)**, **images**, and optional **Outlook (`.msg`)**.
|
|
115
|
+
- **Layout-aware PDF & Image conversion**: Combines native PDF text & table extraction (`pdfplumber` + `pypdfium2`) with automatic OCR on scanned or image-heavy pages, powered by **PP-Structure / PP-StructureV3** and **PaddleOCR** (with **Tesseract** fallback).
|
|
116
|
+
- **Simple multilingual OCR**: Defaults to `--lang vie`, which handles **Vietnamese, English, and Latin-script text** out of the box in PaddleOCR. Combined specifications such as `eng+vie` or `eng+jpn` automatically select the broader recognition model instead of dropping secondary languages.
|
|
117
|
+
- **Phone photo & scan friendly**: Automatically applies EXIF orientation correction, handles multi-page TIFFs, detects multi-column reading order, and removes repeated page headers/footers.
|
|
118
|
+
- **Smart Excel ingestion**: Splits multi-region worksheets into separate tables, expands merged cells, and resolves formula values via cached Excel values, headless LibreOffice recalculation, or optional pure-Python evaluation.
|
|
119
|
+
- **100% local**: Everything runs on your machine (PaddleOCR downloads models once on first run).
|
|
120
|
+
|
|
121
|
+
## Supported Formats
|
|
122
|
+
|
|
123
|
+
| Input | Extensions | Capabilities |
|
|
124
|
+
|-------|------------|--------------|
|
|
125
|
+
| **PDF** | `.pdf` | Native text extraction + automatic OCR on scanned/image-dominated pages, multi-column ordering, repeated header/footer removal, password prompt (`--password`), optional image export (`--assets`). |
|
|
126
|
+
| **Images** | `.png`, `.jpg`, `.jpeg`, `.webp`, `.bmp`, `.tif`, `.tiff` | EXIF auto-rotation, multi-frame TIFF support, layout/table analysis (PP-Structure) or line-grouped plain OCR, automatic Tesseract fallback. |
|
|
127
|
+
| **Word** | `.docx` | Pure-Python OOXML parsing (zero extra dependencies): headings, paragraphs, hyperlinks, nested ordered/unordered lists, tables with merged cells, tracked-deletion filtering, footnotes, optional `--assets` image export. |
|
|
128
|
+
| **PowerPoint** | `.pptx` | True presentation slide ordering, slide titles, visual reading order, nested bullets, tables, **speaker notes**, slide dividers (`---`), optional `--assets` image export. |
|
|
129
|
+
| **Excel** | `.xlsx`, `.xlsm` | Multi-region sheet splitting, merged cell handling, 3-tier formula evaluation (cached → LibreOffice → `xlcalculator`), numeric column alignment. |
|
|
130
|
+
| **Email** | `.eml`, `.msg` | Headers table (`From`, `To`, `Cc`, `Date`), plain text / HTML body conversion, quoted replies, attachment listing & optional `--assets` export (`.msg` via `[outlook]` / BSD `olefile`). |
|
|
131
|
+
| **Web & Tabular** | `.html`, `.htm`, `.csv`, `.tsv` | Clean semantic HTML extraction (headings, lists, code fences, blockquotes, colspan/rowspan tables; strips scripts/styles) and auto-delimiter CSV/TSV tables. |
|
|
132
|
+
|
|
133
|
+
## Installation
|
|
134
|
+
|
|
135
|
+
Requires **Python >= 3.10**.
|
|
136
|
+
|
|
137
|
+
### Direct Install via `pip` (Recommended)
|
|
138
|
+
|
|
139
|
+
Install directly from GitHub in one command without cloning:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Base install (PDF, DOCX, PPTX, Excel, EML, HTML, CSV/TSV)
|
|
143
|
+
pip install git+https://github.com/hotroso/document-to-markdown.git
|
|
144
|
+
|
|
145
|
+
# Recommended: add PaddleOCR + PP-Structure layout/table analysis
|
|
146
|
+
pip install "document-to-markdown[ocr] @ git+https://github.com/hotroso/document-to-markdown.git"
|
|
147
|
+
|
|
148
|
+
# Optional extras: Outlook .msg, Tesseract OCR fallback, or Excel formula engine
|
|
149
|
+
pip install "document-to-markdown[outlook] @ git+https://github.com/hotroso/document-to-markdown.git"
|
|
150
|
+
pip install "document-to-markdown[tesseract] @ git+https://github.com/hotroso/document-to-markdown.git"
|
|
151
|
+
pip install "document-to-markdown[excel-calc] @ git+https://github.com/hotroso/document-to-markdown.git"
|
|
152
|
+
|
|
153
|
+
# Install everything
|
|
154
|
+
pip install "document-to-markdown[all] @ git+https://github.com/hotroso/document-to-markdown.git"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### From Local Source (Development)
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
git clone https://github.com/hotroso/document-to-markdown.git
|
|
161
|
+
cd document-to-markdown
|
|
162
|
+
|
|
163
|
+
pip install -e .
|
|
164
|
+
# or with optional extras: [ocr], [tesseract], [excel-calc], [all]
|
|
165
|
+
pip install -e ".[ocr]"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
> **Note:** On the first OCR / structure run, PaddleOCR automatically downloads detection, recognition, and layout models (a few hundred MB).
|
|
169
|
+
|
|
170
|
+
For detailed workflows, troubleshooting, and examples, see the [Usage Guide](USAGE.md).
|
|
171
|
+
|
|
172
|
+
### Prebuilt Installers & Packages
|
|
173
|
+
|
|
174
|
+
Prebuilt Python packages (`.whl`, `.tar.gz`) and standalone executables (Linux, Windows `.exe`, macOS — bundling native PDF, Excel, and Tesseract OCR support) are automatically built by [GitHub Actions](.github/workflows/release.yml) and published on the [Releases page](https://github.com/hotroso/document-to-markdown/releases). For full PaddleOCR / PP-Structure support, install from source with `pip install -e ".[ocr]"`.
|
|
175
|
+
|
|
176
|
+
## Usage
|
|
177
|
+
|
|
178
|
+
After installation, you can run either `document-to-markdown` or `python -m document_converter.cli`.
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Convert a PDF (outputs report.md only)
|
|
182
|
+
document-to-markdown report.pdf
|
|
183
|
+
|
|
184
|
+
# Convert an image (auto-rotates EXIF, auto-selects PP-Structure / PaddleOCR)
|
|
185
|
+
document-to-markdown scan.png
|
|
186
|
+
|
|
187
|
+
# Convert a bilingual English + Vietnamese PDF with source comments for AI/RAG
|
|
188
|
+
document-to-markdown report.pdf --mode ai --lang eng+vie
|
|
189
|
+
|
|
190
|
+
# Export extracted PDF images (_assets/) and metadata sidecar (.meta.json)
|
|
191
|
+
document-to-markdown report.pdf --assets --meta
|
|
192
|
+
|
|
193
|
+
# Batch convert a whole folder
|
|
194
|
+
document-to-markdown data/input -o data/output --mode ai
|
|
195
|
+
|
|
196
|
+
# Convert an Excel workbook
|
|
197
|
+
document-to-markdown report.xlsx -o report.md
|
|
198
|
+
|
|
199
|
+
# Disable PP-Structure layout analysis (faster plain OCR only)
|
|
200
|
+
document-to-markdown complex.pdf --no-structure
|
|
201
|
+
|
|
202
|
+
# Use lightweight mobile PaddleOCR models (much faster on CPU)
|
|
203
|
+
document-to-markdown scan.pdf --ocr-profile mobile --ocr-version PP-OCRv5
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### CLI Options
|
|
207
|
+
|
|
208
|
+
| Option | Values / Default | Description |
|
|
209
|
+
|--------|------------------|-------------|
|
|
210
|
+
| `inputs` | path(s) | Input file(s) or directory(ies) to convert recursively |
|
|
211
|
+
| `-o`, `--output` | auto (`<input>.md`) | Output `.md` file path or output directory |
|
|
212
|
+
| `--mode` | `balanced` (default), `fidelity`, `ai` | Markdown style (`fidelity`/`ai` include source location comments; `ai` suppresses inline warning blockquotes) |
|
|
213
|
+
| `--ocr` | `auto` (default), `paddle`, `tesseract`, `off` | OCR backend (`auto` prefers PaddleOCR / PP-Structure and falls back to Tesseract) |
|
|
214
|
+
| `--lang` | `vie` (default), `eng`, `eng+vie`, … | OCR language (`vie` covers Vietnamese + English/Latin in PaddleOCR) |
|
|
215
|
+
| `--ocr-profile` | `auto` (default), `mobile`, `server` | PaddleOCR model profile (`mobile` uses lightweight detection for much faster CPU inference) |
|
|
216
|
+
| `--ocr-version` | unset (Paddle default) | PaddleOCR model version (e.g. `PP-OCRv5`, `PP-OCRv4`, `PP-OCRv3`) |
|
|
217
|
+
| `--det-model` | unset | Explicit PaddleOCR text detection model name (e.g. `PP-OCRv5_mobile_det`) |
|
|
218
|
+
| `--rec-model` | unset | Explicit PaddleOCR text recognition model name (e.g. `latin_PP-OCRv5_mobile_rec`) |
|
|
219
|
+
| `--no-structure` | flag | Disable PP-Structure layout/table analysis and use plain OCR only |
|
|
220
|
+
| `--assets`, `--images` | flag | Export images extracted from PDF into `<stem>_assets/` |
|
|
221
|
+
| `--meta` | flag | Export machine-readable `<stem>.meta.json` metadata sidecar |
|
|
222
|
+
| `--preview` | flag | Convert only the first 3 pages of a PDF |
|
|
223
|
+
| `--password` | flag | Prompt for a password on encrypted PDFs |
|
|
224
|
+
| `--no-recalculate` | flag | Skip LibreOffice / pure-Python Excel formula recalculation |
|
|
225
|
+
| `--version` | flag | Print package version and exit |
|
|
226
|
+
| `-v`, `--verbose` | flag | Enable debug logging |
|
|
227
|
+
|
|
228
|
+
## Python API
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
from document_converter import convert_file
|
|
232
|
+
|
|
233
|
+
output_md = convert_file(
|
|
234
|
+
"report.pdf",
|
|
235
|
+
"output/report.md",
|
|
236
|
+
mode="balanced", # "balanced" | "fidelity" | "ai"
|
|
237
|
+
ocr="auto", # "auto" | "paddle" | "tesseract" | "off"
|
|
238
|
+
ocr_lang="vie", # "vie", "eng", "eng+vie", ...
|
|
239
|
+
ocr_profile="auto", # "auto" | "mobile" | "server"
|
|
240
|
+
ocr_version=None, # e.g. "PP-OCRv5", "PP-OCRv4"
|
|
241
|
+
det_model=None, # e.g. "PP-OCRv5_mobile_det"
|
|
242
|
+
rec_model=None, # e.g. "latin_PP-OCRv5_mobile_rec"
|
|
243
|
+
export_images=False, # True to create output/report_assets/
|
|
244
|
+
export_meta=False, # True to create output/report.meta.json
|
|
245
|
+
)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## How It Works
|
|
249
|
+
|
|
250
|
+
### PDF & Image Layout Analysis
|
|
251
|
+
1. For PDFs in `--ocr auto` mode, pages with native text and ruled tables are extracted directly via `pdfplumber` with multi-column clustering.
|
|
252
|
+
2. Scanned pages (little native text) or image-dominated pages (images covering `>= 35%` of the page) are rendered with `pypdfium2` and automatically routed to OCR.
|
|
253
|
+
3. When PaddleOCR + PP-Structure is available (default), layout regions (titles, headings, paragraphs, lists, HTML tables) are reconstructed in reading order. Otherwise it falls back gracefully to line-grouped plain PaddleOCR or Tesseract.
|
|
254
|
+
|
|
255
|
+
### Excel Formula Evaluation (Multi-Tier)
|
|
256
|
+
When a workbook contains formulas, the converter resolves cell values in order:
|
|
257
|
+
1. **Cached values** already saved in the `.xlsx` file (fastest).
|
|
258
|
+
2. **LibreOffice** headless recalculation on a temporary copy (most compatible, requires `soffice` or `libreoffice` on `PATH`).
|
|
259
|
+
3. **Pure-Python** evaluation via the optional MIT-licensed `xlcalculator` package (`pip install -e ".[excel-calc]"`).
|
|
260
|
+
4. Retain the formula text and emit a conversion warning if no calculated value is available.
|
|
261
|
+
|
|
262
|
+
## Limitations
|
|
263
|
+
|
|
264
|
+
- Legacy `.xls`, `.doc`, and `.ppt` files are not supported directly (convert them to `.xlsx`/`.docx`/`.pptx` first, e.g. with LibreOffice).
|
|
265
|
+
- Heavily nested tables or handwritten forms remain challenging for local OCR.
|
|
266
|
+
- PP-Structure with high-DPI page rendering uses more CPU/RAM than plain native PDF text extraction.
|
|
267
|
+
- Pure-Python `xlcalculator` coverage is partial for complex array formulas or Excel-specific functions; LibreOffice is recommended for formula-heavy workbooks.
|
|
268
|
+
- Mixing two completely different writing systems in a single PaddleOCR pass (e.g., Vietnamese + Japanese on the same page) is limited by single-model recognition dictionaries; use `--ocr tesseract` with system language packs when needed.
|
|
269
|
+
|
|
270
|
+
## Changelog
|
|
271
|
+
|
|
272
|
+
### 0.6.1
|
|
273
|
+
- Make OCR engine detection truly lazy using `importlib.util.find_spec` and deferring detection in `convert_pdf` until a page actually needs OCR, avoiding heavy PaddleOCR / PaddleX startup imports on digital-only PDFs
|
|
274
|
+
|
|
275
|
+
### 0.6.0
|
|
276
|
+
- Switch project license to **MIT License with Commons Clause v1.0** (source-available) backed by a 100% permissive dependency stack (no AGPL, GPL, or EUPL dependencies)
|
|
277
|
+
- Replace `PyMuPDF` (AGPL-3.0) with `pdfplumber` (MIT) + `pypdfium2` (Apache-2.0 / BSD-3-Clause), adding native ruled-table detection for digital PDFs
|
|
278
|
+
- Replace `extract-msg` (GPL-3.0) with a native OLE2/MAPI `.msg` parser using `olefile` (BSD-2-Clause)
|
|
279
|
+
- Replace `formulas` (EUPL-1.2) with `xlcalculator` (MIT) for optional pure-Python Excel formula evaluation
|
|
280
|
+
|
|
281
|
+
### 0.5.0
|
|
282
|
+
- Add zero-dependency native adapters for Word (`.docx` with headings, nested lists, merged-cell tables, hyperlinks, tracked-deletion filtering, footnotes, `--assets`), PowerPoint (`.pptx` with true slide order, bullets, tables, speaker notes, `--assets`), Email (`.eml`), HTML (`.html`/`.htm` with code blocks, blockquotes, colspan/rowspan tables), and CSV/TSV (`.csv`/`.tsv`)
|
|
283
|
+
- Add Outlook `.msg` email support via optional `[outlook]` extra (`extract-msg`, bundled in standalone release binaries)
|
|
284
|
+
- Enhance Markdown renderer with nested list indentation, fenced code blocks, and blockquotes
|
|
285
|
+
|
|
286
|
+
### 0.4.0
|
|
287
|
+
- Add optional PaddleOCR model selection across CLI and Python API while preserving defaults: `--ocr-profile` (`auto` | `mobile` | `server`), `--ocr-version` (e.g. `PP-OCRv5`, `PP-OCRv4`, `PP-OCRv3`), `--det-model`, and `--rec-model`
|
|
288
|
+
- Key cached OCR / PP-Structure engines by full model configuration and keep graceful fallbacks for `PPStructureV3` and PaddleOCR 2.x
|
|
289
|
+
|
|
290
|
+
### 0.3.3
|
|
291
|
+
- Fix `ValueError: The truth value of an array with more than one element is ambiguous` when reading NumPy array outputs (`rec_texts`, `rec_scores`, `rec_boxes`, `dt_polys`, `bbox`) from PaddleOCR 3.x / PP-Structure and normalize NumPy bounding boxes in `_bbox_rect`
|
|
292
|
+
- Add cross-platform PaddlePaddle 3.x PIR/oneDNN (`ConvertPirAttribute2RuntimeAttribute`) mitigation: proactively disable MKLDNN by default on Windows (`PADDLE_PDX_ENABLE_MKLDNN_BYDEFAULT=0` + `enable_mkldnn=False`, overridable via env), honor `FLAGS_use_mkldnn=0` on all platforms, and auto-retry with `enable_mkldnn=False` at runtime if the error occurs
|
|
293
|
+
|
|
294
|
+
### 0.3.2
|
|
295
|
+
- Fix PaddleOCR 3.x+ initialization by omitting the removed `show_log=False` constructor argument and silencing verbose logs via Python `logging`
|
|
296
|
+
- Preserve PaddleOCR 2.x constructor fallback (`use_angle_cls`, `show_log=False`, `use_gpu=False`) and handle both `TypeError` and `ValueError` fallbacks across `PaddleOCR`, `PPStructureV3`, and classic `PPStructure`
|
|
297
|
+
|
|
298
|
+
### 0.3.1
|
|
299
|
+
- Make `.md` the sole default output; opt in to `_assets` and `.meta.json` via `--assets` (`--images`) and `--meta`
|
|
300
|
+
- Default `--lang` to `vie` (covers Vietnamese + English/Latin in PaddleOCR) and preserve secondary non-English languages in multi-language specs like `eng+vie`
|
|
301
|
+
- Add `map_lang_for_tesseract` and shared Tesseract fallback for image inputs
|
|
302
|
+
- Fix `PPStructureV3` pre-formatted Markdown escaping and avoid promoting running page headers to headings
|
|
303
|
+
- Improve plain OCR visual-line sorting, dynamic paragraph spacing, and multi-column gutter detection
|
|
304
|
+
- Auto-apply EXIF orientation, support multi-frame TIFFs, and detect image-dominated PDF pages for OCR
|
|
305
|
+
|
|
306
|
+
### 0.3.0
|
|
307
|
+
- PP-Structure / PP-StructureV3 integration for layout, tables, and reading order
|
|
308
|
+
- Direct image file support
|
|
309
|
+
- Multi-column clustering for native PDF blocks and OCR lines
|
|
310
|
+
- `--no-structure` flag
|
|
311
|
+
|
|
312
|
+
### 0.2.0
|
|
313
|
+
- Primary OCR engine switched to PaddleOCR (Tesseract kept as fallback)
|
|
314
|
+
- Language mapping, lazy model loading, improved error recovery
|
|
315
|
+
|
|
316
|
+
### 0.1.0
|
|
317
|
+
- Initial foundation (PDF + Excel + Tesseract)
|
|
318
|
+
|
|
319
|
+
## License
|
|
320
|
+
|
|
321
|
+
Released under the [MIT License with Commons Clause v1.0](LICENSE) (source-available).
|
|
322
|
+
|
|
323
|
+
- **Free to use, modify, and integrate** for personal, educational, research, and internal business workflows.
|
|
324
|
+
- **Commercial resale / hosted SaaS restriction**: Under the Commons Clause, selling the software itself or offering a paid product/hosted service whose value derives substantially from `document-to-markdown` requires a separate commercial license from **hotroso** (`hotrogiaiphapso@gmail.com`).
|
|
325
|
+
- All runtime dependencies use permissive licenses (MIT, Apache-2.0, BSD, HPND).
|
|
326
|
+
|
|
327
|
+
## Repository Stats
|
|
328
|
+
|
|
329
|
+
[](https://star-history.com/#hotroso/document-to-markdown&Date)
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Document to Markdown
|
|
2
|
+
|
|
3
|
+
[](https://github.com/hotroso/document-to-markdown/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/hotroso/document-to-markdown/releases)
|
|
5
|
+
[](https://github.com/hotroso/document-to-markdown/releases)
|
|
6
|
+
[](pyproject.toml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://github.com/hotroso/document-to-markdown/stargazers)
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
Local, zero-config converter for **PDF**, **Office (DOCX, PPTX, Excel)**, **Email (EML/Outlook MSG)**, **HTML**, **CSV/TSV**, and **images** into clean, AI/RAG-ready **Markdown**.
|
|
13
|
+
|
|
14
|
+
Designed for personal and enterprise AI, LLM, and RAG workflows where document layouts vary wildly and you want clean `.md` files out of the box without complex setup or cloud APIs.
|
|
15
|
+
|
|
16
|
+
## Highlights
|
|
17
|
+
|
|
18
|
+
- **Clean Markdown by default**: Outputs only the `.md` file by default. Extracted image/attachment folders (`_assets`) and JSON metadata sidecars (`.meta.json`) are opt-in via `--assets` and `--meta`.
|
|
19
|
+
- **Broad local document support out of the box**: Zero extra dependencies for **Word (`.docx`)**, **PowerPoint (`.pptx` with speaker notes)**, **Email (`.eml`)**, **HTML**, and **CSV/TSV**, plus **PDF**, **Excel (`.xlsx`/`.xlsm`)**, **images**, and optional **Outlook (`.msg`)**.
|
|
20
|
+
- **Layout-aware PDF & Image conversion**: Combines native PDF text & table extraction (`pdfplumber` + `pypdfium2`) with automatic OCR on scanned or image-heavy pages, powered by **PP-Structure / PP-StructureV3** and **PaddleOCR** (with **Tesseract** fallback).
|
|
21
|
+
- **Simple multilingual OCR**: Defaults to `--lang vie`, which handles **Vietnamese, English, and Latin-script text** out of the box in PaddleOCR. Combined specifications such as `eng+vie` or `eng+jpn` automatically select the broader recognition model instead of dropping secondary languages.
|
|
22
|
+
- **Phone photo & scan friendly**: Automatically applies EXIF orientation correction, handles multi-page TIFFs, detects multi-column reading order, and removes repeated page headers/footers.
|
|
23
|
+
- **Smart Excel ingestion**: Splits multi-region worksheets into separate tables, expands merged cells, and resolves formula values via cached Excel values, headless LibreOffice recalculation, or optional pure-Python evaluation.
|
|
24
|
+
- **100% local**: Everything runs on your machine (PaddleOCR downloads models once on first run).
|
|
25
|
+
|
|
26
|
+
## Supported Formats
|
|
27
|
+
|
|
28
|
+
| Input | Extensions | Capabilities |
|
|
29
|
+
|-------|------------|--------------|
|
|
30
|
+
| **PDF** | `.pdf` | Native text extraction + automatic OCR on scanned/image-dominated pages, multi-column ordering, repeated header/footer removal, password prompt (`--password`), optional image export (`--assets`). |
|
|
31
|
+
| **Images** | `.png`, `.jpg`, `.jpeg`, `.webp`, `.bmp`, `.tif`, `.tiff` | EXIF auto-rotation, multi-frame TIFF support, layout/table analysis (PP-Structure) or line-grouped plain OCR, automatic Tesseract fallback. |
|
|
32
|
+
| **Word** | `.docx` | Pure-Python OOXML parsing (zero extra dependencies): headings, paragraphs, hyperlinks, nested ordered/unordered lists, tables with merged cells, tracked-deletion filtering, footnotes, optional `--assets` image export. |
|
|
33
|
+
| **PowerPoint** | `.pptx` | True presentation slide ordering, slide titles, visual reading order, nested bullets, tables, **speaker notes**, slide dividers (`---`), optional `--assets` image export. |
|
|
34
|
+
| **Excel** | `.xlsx`, `.xlsm` | Multi-region sheet splitting, merged cell handling, 3-tier formula evaluation (cached → LibreOffice → `xlcalculator`), numeric column alignment. |
|
|
35
|
+
| **Email** | `.eml`, `.msg` | Headers table (`From`, `To`, `Cc`, `Date`), plain text / HTML body conversion, quoted replies, attachment listing & optional `--assets` export (`.msg` via `[outlook]` / BSD `olefile`). |
|
|
36
|
+
| **Web & Tabular** | `.html`, `.htm`, `.csv`, `.tsv` | Clean semantic HTML extraction (headings, lists, code fences, blockquotes, colspan/rowspan tables; strips scripts/styles) and auto-delimiter CSV/TSV tables. |
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
Requires **Python >= 3.10**.
|
|
41
|
+
|
|
42
|
+
### Direct Install via `pip` (Recommended)
|
|
43
|
+
|
|
44
|
+
Install directly from GitHub in one command without cloning:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Base install (PDF, DOCX, PPTX, Excel, EML, HTML, CSV/TSV)
|
|
48
|
+
pip install git+https://github.com/hotroso/document-to-markdown.git
|
|
49
|
+
|
|
50
|
+
# Recommended: add PaddleOCR + PP-Structure layout/table analysis
|
|
51
|
+
pip install "document-to-markdown[ocr] @ git+https://github.com/hotroso/document-to-markdown.git"
|
|
52
|
+
|
|
53
|
+
# Optional extras: Outlook .msg, Tesseract OCR fallback, or Excel formula engine
|
|
54
|
+
pip install "document-to-markdown[outlook] @ git+https://github.com/hotroso/document-to-markdown.git"
|
|
55
|
+
pip install "document-to-markdown[tesseract] @ git+https://github.com/hotroso/document-to-markdown.git"
|
|
56
|
+
pip install "document-to-markdown[excel-calc] @ git+https://github.com/hotroso/document-to-markdown.git"
|
|
57
|
+
|
|
58
|
+
# Install everything
|
|
59
|
+
pip install "document-to-markdown[all] @ git+https://github.com/hotroso/document-to-markdown.git"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### From Local Source (Development)
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/hotroso/document-to-markdown.git
|
|
66
|
+
cd document-to-markdown
|
|
67
|
+
|
|
68
|
+
pip install -e .
|
|
69
|
+
# or with optional extras: [ocr], [tesseract], [excel-calc], [all]
|
|
70
|
+
pip install -e ".[ocr]"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> **Note:** On the first OCR / structure run, PaddleOCR automatically downloads detection, recognition, and layout models (a few hundred MB).
|
|
74
|
+
|
|
75
|
+
For detailed workflows, troubleshooting, and examples, see the [Usage Guide](USAGE.md).
|
|
76
|
+
|
|
77
|
+
### Prebuilt Installers & Packages
|
|
78
|
+
|
|
79
|
+
Prebuilt Python packages (`.whl`, `.tar.gz`) and standalone executables (Linux, Windows `.exe`, macOS — bundling native PDF, Excel, and Tesseract OCR support) are automatically built by [GitHub Actions](.github/workflows/release.yml) and published on the [Releases page](https://github.com/hotroso/document-to-markdown/releases). For full PaddleOCR / PP-Structure support, install from source with `pip install -e ".[ocr]"`.
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
After installation, you can run either `document-to-markdown` or `python -m document_converter.cli`.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Convert a PDF (outputs report.md only)
|
|
87
|
+
document-to-markdown report.pdf
|
|
88
|
+
|
|
89
|
+
# Convert an image (auto-rotates EXIF, auto-selects PP-Structure / PaddleOCR)
|
|
90
|
+
document-to-markdown scan.png
|
|
91
|
+
|
|
92
|
+
# Convert a bilingual English + Vietnamese PDF with source comments for AI/RAG
|
|
93
|
+
document-to-markdown report.pdf --mode ai --lang eng+vie
|
|
94
|
+
|
|
95
|
+
# Export extracted PDF images (_assets/) and metadata sidecar (.meta.json)
|
|
96
|
+
document-to-markdown report.pdf --assets --meta
|
|
97
|
+
|
|
98
|
+
# Batch convert a whole folder
|
|
99
|
+
document-to-markdown data/input -o data/output --mode ai
|
|
100
|
+
|
|
101
|
+
# Convert an Excel workbook
|
|
102
|
+
document-to-markdown report.xlsx -o report.md
|
|
103
|
+
|
|
104
|
+
# Disable PP-Structure layout analysis (faster plain OCR only)
|
|
105
|
+
document-to-markdown complex.pdf --no-structure
|
|
106
|
+
|
|
107
|
+
# Use lightweight mobile PaddleOCR models (much faster on CPU)
|
|
108
|
+
document-to-markdown scan.pdf --ocr-profile mobile --ocr-version PP-OCRv5
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### CLI Options
|
|
112
|
+
|
|
113
|
+
| Option | Values / Default | Description |
|
|
114
|
+
|--------|------------------|-------------|
|
|
115
|
+
| `inputs` | path(s) | Input file(s) or directory(ies) to convert recursively |
|
|
116
|
+
| `-o`, `--output` | auto (`<input>.md`) | Output `.md` file path or output directory |
|
|
117
|
+
| `--mode` | `balanced` (default), `fidelity`, `ai` | Markdown style (`fidelity`/`ai` include source location comments; `ai` suppresses inline warning blockquotes) |
|
|
118
|
+
| `--ocr` | `auto` (default), `paddle`, `tesseract`, `off` | OCR backend (`auto` prefers PaddleOCR / PP-Structure and falls back to Tesseract) |
|
|
119
|
+
| `--lang` | `vie` (default), `eng`, `eng+vie`, … | OCR language (`vie` covers Vietnamese + English/Latin in PaddleOCR) |
|
|
120
|
+
| `--ocr-profile` | `auto` (default), `mobile`, `server` | PaddleOCR model profile (`mobile` uses lightweight detection for much faster CPU inference) |
|
|
121
|
+
| `--ocr-version` | unset (Paddle default) | PaddleOCR model version (e.g. `PP-OCRv5`, `PP-OCRv4`, `PP-OCRv3`) |
|
|
122
|
+
| `--det-model` | unset | Explicit PaddleOCR text detection model name (e.g. `PP-OCRv5_mobile_det`) |
|
|
123
|
+
| `--rec-model` | unset | Explicit PaddleOCR text recognition model name (e.g. `latin_PP-OCRv5_mobile_rec`) |
|
|
124
|
+
| `--no-structure` | flag | Disable PP-Structure layout/table analysis and use plain OCR only |
|
|
125
|
+
| `--assets`, `--images` | flag | Export images extracted from PDF into `<stem>_assets/` |
|
|
126
|
+
| `--meta` | flag | Export machine-readable `<stem>.meta.json` metadata sidecar |
|
|
127
|
+
| `--preview` | flag | Convert only the first 3 pages of a PDF |
|
|
128
|
+
| `--password` | flag | Prompt for a password on encrypted PDFs |
|
|
129
|
+
| `--no-recalculate` | flag | Skip LibreOffice / pure-Python Excel formula recalculation |
|
|
130
|
+
| `--version` | flag | Print package version and exit |
|
|
131
|
+
| `-v`, `--verbose` | flag | Enable debug logging |
|
|
132
|
+
|
|
133
|
+
## Python API
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from document_converter import convert_file
|
|
137
|
+
|
|
138
|
+
output_md = convert_file(
|
|
139
|
+
"report.pdf",
|
|
140
|
+
"output/report.md",
|
|
141
|
+
mode="balanced", # "balanced" | "fidelity" | "ai"
|
|
142
|
+
ocr="auto", # "auto" | "paddle" | "tesseract" | "off"
|
|
143
|
+
ocr_lang="vie", # "vie", "eng", "eng+vie", ...
|
|
144
|
+
ocr_profile="auto", # "auto" | "mobile" | "server"
|
|
145
|
+
ocr_version=None, # e.g. "PP-OCRv5", "PP-OCRv4"
|
|
146
|
+
det_model=None, # e.g. "PP-OCRv5_mobile_det"
|
|
147
|
+
rec_model=None, # e.g. "latin_PP-OCRv5_mobile_rec"
|
|
148
|
+
export_images=False, # True to create output/report_assets/
|
|
149
|
+
export_meta=False, # True to create output/report.meta.json
|
|
150
|
+
)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## How It Works
|
|
154
|
+
|
|
155
|
+
### PDF & Image Layout Analysis
|
|
156
|
+
1. For PDFs in `--ocr auto` mode, pages with native text and ruled tables are extracted directly via `pdfplumber` with multi-column clustering.
|
|
157
|
+
2. Scanned pages (little native text) or image-dominated pages (images covering `>= 35%` of the page) are rendered with `pypdfium2` and automatically routed to OCR.
|
|
158
|
+
3. When PaddleOCR + PP-Structure is available (default), layout regions (titles, headings, paragraphs, lists, HTML tables) are reconstructed in reading order. Otherwise it falls back gracefully to line-grouped plain PaddleOCR or Tesseract.
|
|
159
|
+
|
|
160
|
+
### Excel Formula Evaluation (Multi-Tier)
|
|
161
|
+
When a workbook contains formulas, the converter resolves cell values in order:
|
|
162
|
+
1. **Cached values** already saved in the `.xlsx` file (fastest).
|
|
163
|
+
2. **LibreOffice** headless recalculation on a temporary copy (most compatible, requires `soffice` or `libreoffice` on `PATH`).
|
|
164
|
+
3. **Pure-Python** evaluation via the optional MIT-licensed `xlcalculator` package (`pip install -e ".[excel-calc]"`).
|
|
165
|
+
4. Retain the formula text and emit a conversion warning if no calculated value is available.
|
|
166
|
+
|
|
167
|
+
## Limitations
|
|
168
|
+
|
|
169
|
+
- Legacy `.xls`, `.doc`, and `.ppt` files are not supported directly (convert them to `.xlsx`/`.docx`/`.pptx` first, e.g. with LibreOffice).
|
|
170
|
+
- Heavily nested tables or handwritten forms remain challenging for local OCR.
|
|
171
|
+
- PP-Structure with high-DPI page rendering uses more CPU/RAM than plain native PDF text extraction.
|
|
172
|
+
- Pure-Python `xlcalculator` coverage is partial for complex array formulas or Excel-specific functions; LibreOffice is recommended for formula-heavy workbooks.
|
|
173
|
+
- Mixing two completely different writing systems in a single PaddleOCR pass (e.g., Vietnamese + Japanese on the same page) is limited by single-model recognition dictionaries; use `--ocr tesseract` with system language packs when needed.
|
|
174
|
+
|
|
175
|
+
## Changelog
|
|
176
|
+
|
|
177
|
+
### 0.6.1
|
|
178
|
+
- Make OCR engine detection truly lazy using `importlib.util.find_spec` and deferring detection in `convert_pdf` until a page actually needs OCR, avoiding heavy PaddleOCR / PaddleX startup imports on digital-only PDFs
|
|
179
|
+
|
|
180
|
+
### 0.6.0
|
|
181
|
+
- Switch project license to **MIT License with Commons Clause v1.0** (source-available) backed by a 100% permissive dependency stack (no AGPL, GPL, or EUPL dependencies)
|
|
182
|
+
- Replace `PyMuPDF` (AGPL-3.0) with `pdfplumber` (MIT) + `pypdfium2` (Apache-2.0 / BSD-3-Clause), adding native ruled-table detection for digital PDFs
|
|
183
|
+
- Replace `extract-msg` (GPL-3.0) with a native OLE2/MAPI `.msg` parser using `olefile` (BSD-2-Clause)
|
|
184
|
+
- Replace `formulas` (EUPL-1.2) with `xlcalculator` (MIT) for optional pure-Python Excel formula evaluation
|
|
185
|
+
|
|
186
|
+
### 0.5.0
|
|
187
|
+
- Add zero-dependency native adapters for Word (`.docx` with headings, nested lists, merged-cell tables, hyperlinks, tracked-deletion filtering, footnotes, `--assets`), PowerPoint (`.pptx` with true slide order, bullets, tables, speaker notes, `--assets`), Email (`.eml`), HTML (`.html`/`.htm` with code blocks, blockquotes, colspan/rowspan tables), and CSV/TSV (`.csv`/`.tsv`)
|
|
188
|
+
- Add Outlook `.msg` email support via optional `[outlook]` extra (`extract-msg`, bundled in standalone release binaries)
|
|
189
|
+
- Enhance Markdown renderer with nested list indentation, fenced code blocks, and blockquotes
|
|
190
|
+
|
|
191
|
+
### 0.4.0
|
|
192
|
+
- Add optional PaddleOCR model selection across CLI and Python API while preserving defaults: `--ocr-profile` (`auto` | `mobile` | `server`), `--ocr-version` (e.g. `PP-OCRv5`, `PP-OCRv4`, `PP-OCRv3`), `--det-model`, and `--rec-model`
|
|
193
|
+
- Key cached OCR / PP-Structure engines by full model configuration and keep graceful fallbacks for `PPStructureV3` and PaddleOCR 2.x
|
|
194
|
+
|
|
195
|
+
### 0.3.3
|
|
196
|
+
- Fix `ValueError: The truth value of an array with more than one element is ambiguous` when reading NumPy array outputs (`rec_texts`, `rec_scores`, `rec_boxes`, `dt_polys`, `bbox`) from PaddleOCR 3.x / PP-Structure and normalize NumPy bounding boxes in `_bbox_rect`
|
|
197
|
+
- Add cross-platform PaddlePaddle 3.x PIR/oneDNN (`ConvertPirAttribute2RuntimeAttribute`) mitigation: proactively disable MKLDNN by default on Windows (`PADDLE_PDX_ENABLE_MKLDNN_BYDEFAULT=0` + `enable_mkldnn=False`, overridable via env), honor `FLAGS_use_mkldnn=0` on all platforms, and auto-retry with `enable_mkldnn=False` at runtime if the error occurs
|
|
198
|
+
|
|
199
|
+
### 0.3.2
|
|
200
|
+
- Fix PaddleOCR 3.x+ initialization by omitting the removed `show_log=False` constructor argument and silencing verbose logs via Python `logging`
|
|
201
|
+
- Preserve PaddleOCR 2.x constructor fallback (`use_angle_cls`, `show_log=False`, `use_gpu=False`) and handle both `TypeError` and `ValueError` fallbacks across `PaddleOCR`, `PPStructureV3`, and classic `PPStructure`
|
|
202
|
+
|
|
203
|
+
### 0.3.1
|
|
204
|
+
- Make `.md` the sole default output; opt in to `_assets` and `.meta.json` via `--assets` (`--images`) and `--meta`
|
|
205
|
+
- Default `--lang` to `vie` (covers Vietnamese + English/Latin in PaddleOCR) and preserve secondary non-English languages in multi-language specs like `eng+vie`
|
|
206
|
+
- Add `map_lang_for_tesseract` and shared Tesseract fallback for image inputs
|
|
207
|
+
- Fix `PPStructureV3` pre-formatted Markdown escaping and avoid promoting running page headers to headings
|
|
208
|
+
- Improve plain OCR visual-line sorting, dynamic paragraph spacing, and multi-column gutter detection
|
|
209
|
+
- Auto-apply EXIF orientation, support multi-frame TIFFs, and detect image-dominated PDF pages for OCR
|
|
210
|
+
|
|
211
|
+
### 0.3.0
|
|
212
|
+
- PP-Structure / PP-StructureV3 integration for layout, tables, and reading order
|
|
213
|
+
- Direct image file support
|
|
214
|
+
- Multi-column clustering for native PDF blocks and OCR lines
|
|
215
|
+
- `--no-structure` flag
|
|
216
|
+
|
|
217
|
+
### 0.2.0
|
|
218
|
+
- Primary OCR engine switched to PaddleOCR (Tesseract kept as fallback)
|
|
219
|
+
- Language mapping, lazy model loading, improved error recovery
|
|
220
|
+
|
|
221
|
+
### 0.1.0
|
|
222
|
+
- Initial foundation (PDF + Excel + Tesseract)
|
|
223
|
+
|
|
224
|
+
## License
|
|
225
|
+
|
|
226
|
+
Released under the [MIT License with Commons Clause v1.0](LICENSE) (source-available).
|
|
227
|
+
|
|
228
|
+
- **Free to use, modify, and integrate** for personal, educational, research, and internal business workflows.
|
|
229
|
+
- **Commercial resale / hosted SaaS restriction**: Under the Commons Clause, selling the software itself or offering a paid product/hosted service whose value derives substantially from `document-to-markdown` requires a separate commercial license from **hotroso** (`hotrogiaiphapso@gmail.com`).
|
|
230
|
+
- All runtime dependencies use permissive licenses (MIT, Apache-2.0, BSD, HPND).
|
|
231
|
+
|
|
232
|
+
## Repository Stats
|
|
233
|
+
|
|
234
|
+
[](https://star-history.com/#hotroso/document-to-markdown&Date)
|