Install
openclaw skills install pdf-to-word-with-formatPDF带格式精确转换成Word Skill。将PDF文档精确转换为Word文档,完整保留原始字体名称、字号(pt)、段落格式(行间距1.5倍、段前段后间距、首行缩进2字符)、文本对齐方式(居中/两端对齐)、文本格式(粗体、斜体、下划线、颜色)、表格和图片等。支持中文字体智能映射(宋体→宋体、黑体→黑体、楷体→楷体等)。触发场景:用户说"PDF转Word"、"PDF转Word保留格式"、"PDF精准转Word"、"PDF format to Word"、"Convert PDF with formatting"等。
openclaw skills install pdf-to-word-with-format本 skill 提供高精度PDF转Word转换服务,最大程度保留原始文档的所有格式信息。
精确字体映射
字号精确转换
段落格式保留
文本对齐
文本格式
表格支持
图片支持
python convert.py <输入PDF> --output <输出Word>
python convert.py <PDF文件夹> --batch --output <输出文件夹>
python convert.py 文档.pdf --pages 0-5 --output 文档.docx
首次使用需安装依赖:
pip install pymupdf python-docx
# 基本转换
python convert.py 报告.pdf --output 报告.docx
# 批量转换文件夹中所有PDF
python convert.py ./pdfs/ --batch --output ./words/
# 转换前10页
python convert.py 文档.pdf --pages 0-9 --output 文档.docx
# 指定起始页和结束页
python convert.py 长文档.pdf --start 5 --end 15 --output 部分.docx
.docx 格式,可用 Microsoft Word 或 WPS 打开本 skill 基于以下技术实现:
提取的格式信息包括:
| PDF字体 | Word字体 |
|---|---|
| 宋体, SimSun | 宋体 |
| 黑体, SimHei | 黑体 |
| 楷体, SimKai | 楷体_GB2312 |
| 仿宋, SimFang | 仿宋_GB2312 |
| Times New Roman | Times New Roman |
| Arial, Helvetica | Arial |
| 微软雅黑, Microsoft YaHei | 微软雅黑 |