Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning " AI Answers

如何将 SmolDocling 的输出转换为常用办公格式?

2025-08-28 1.5 K

SmolDocling 的标准输出 DocTags 可通过 docling_core 库实现多格式转换:

基础转换方法

  • 转 Markdown: Use export_to_markdown() 方法,完美保留标题层级和代码块
  • 转 HTML:适合网页发布,会原样保留表格样式
  • 转 LaTeX:学术用户可用此处理数学公式

高级处理技巧

  • 合并多页文档:先用列表收集各页 DocTags,再用 Document.merge()
  • 样式定制:通过修改 CSS 模板调整 HTML 输出样式
  • 批量转换:结合 glob 模块实现文件夹批量处理

转换示例代码:
doc = DoclingDocument(name="报告")
doc.load_from_doctags(doctags)
with open("output.md", "w") as f:
f.write(doc.export_to_markdown())

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

Top

en_USEnglish