內建 converter 全部在本機離線運作。需要更高品質(掃描 PDF、複雜表格、影片、結構化欄位)時, MarkItDown 提供兩條 Azure 雲端路徑。
| 能力 | 內建 converter | Document Intelligence | Content Understanding |
|---|---|---|---|
| 文件轉換 | 離線、格式特定抽取 | 雲端版面分析 | 雲端多模態抽取 |
| 結構化欄位 | 不支援 | 此整合未暴露 | YAML front matter(analyzer 欄位) |
| 自訂 analyzer | 不支援 | 此整合不可設定 | cu_analyzer_id 支援 |
| 音訊 / 影片 | 僅基本音訊、無影片 | 不支援 | 音訊 + 影片 analyzer |
| 成本 | 純本機 | Azure API 計費 | Azure API 計費 |
cu_endpoint 自動路由文件/圖/音/影。pip install 'markitdown[az-content-understanding]'
# CLI
markitdown report.pdf --use-cu --cu-endpoint "<endpoint>"
# Python(零設定,自動依檔案類型選 analyzer)
from markitdown import MarkItDown
md = MarkItDown(cu_endpoint="<endpoint>")
print(md.convert("report.pdf").markdown) # 文件 → prebuilt-documentSearch
print(md.convert("meeting.mp4").markdown) # 影片 → prebuilt-videoSearch
# 自訂 analyzer(領域欄位抽取)
md = MarkItDown(cu_endpoint="<endpoint>", cu_analyzer_id="my-invoice-analyzer")
print(md.convert("invoice.pdf").markdown)
# 輸出含 YAML front matter:
# ---
# contentType: document
# fields:
# VendorName: CONTOSO LTD.
# InvoiceDate: '2019-11-15'
# ---
# <!-- page 1 -->
convert() 呼叫,只要是 CU 路由的格式,
就是一筆可計費的 Azure API 呼叫。用 cu_file_types 限制哪些格式才走 CU:from markitdown.converters import ContentUnderstandingFileType
md = MarkItDown(
cu_endpoint="<endpoint>",
cu_file_types=[ContentUnderstandingFileType.PDF], # 只有 PDF 走 CU
)
pip install 'markitdown[az-doc-intel]'
# CLI
markitdown file.pdf -o document.md -d -e "<document_intelligence_endpoint>"
# Python
md = MarkItDown(docintel_endpoint="<document_intelligence_endpoint>")
result = md.convert("test.pdf")
print(result.text_content)
Azure 兩條路徑都需要雲端資源與計費,本站不實跑;以上內容為官方 README 的忠實翻譯與對照整理。 建立資源的指引見 Document Intelligence 與 Content Understanding 官方文件。