Install
openclaw skills install ebook-to-mdConvert PDF/PNG/JPEG/MOBI/EPUB to Markdown. Uses Baidu OCR only. Use when 扫描PDF转Markdown、pdf ocr、图像识别、电子书转Markdown、ebook to markdown.
openclaw skills install ebook-to-md将 PDF、图片、MOBI、EPUB 转为 Markdown。仅使用百度 OCR。
图片 OCR 输出会自动添加 Markdown 分段:首行若为短标题则转为 ##,对话段落前插入空行。
仅输出 Markdown(.md)。
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| input_path | string | yes | - | 文档路径(pdf/png/jpeg/mobi/epub)或 base64 图片 |
| output_path | string | no | - | 输出文件路径 |
| ocr_backend | string | no | "baidu" | 保留参数,仅支持百度 |
| inline_images | bool | no | true | 图片是否 base64 内联 |
# PDF 转 Markdown(百度 OCR)
python scripts/ebook_to_md.py --input_path=./scanned.pdf
# 图片转 Markdown
python scripts/ebook_to_md.py --input_path=./screenshot.png
# 指定输出路径
python scripts/ebook_to_md.py --input_path=./report.pdf --output_path=./report.md
pip install requests
brew install calibreBAIDU_OCR_API_KEY、BAIDU_OCR_SECRET_KEYfrom skills.ebook_to_md import main
main(input_path='./report.pdf', output_path='./report.md')
main(input_path='./image.png') # 图片识别
main(input_path='./book.epub', output_path='./book.md')
main(input_path='./book.mobi', output_path='./book.md')
成功:返回字符串,含预览;若指定 output_path 则写入文件。 失败:返回 "错误: ..."