file-to-pdf
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "file-to-pdf" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-f6dd0fadfeb44377647f801ee3e3f93142c5f147086fb02bc8cb03eb9f0c7a2d. Verify the upstream source and version against https://skillhub.cn/skills/user_455624ec/file-to-pdf before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Batch convert various files to PDF. Supports Office documents (Word/Excel/PowerPoint), images (JPG/PNG/BMP/GIF/WebP/TIFF), HTML pages, Markdown files, and plain text. Triggered when a user requests converting files to PDF, exporting PDFs, merging images into a PDF, or bulk converting document formats.
Introduction source: third_party · user_455624ec · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Not specified in the source documentation.
- Inputs and outputs
- python scripts/convert_to_pdf.py input.docx --output ./pdf_output/
- Software, accounts and paid services
- Not specified in the source documentation.
- Limits and differences
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: file-to-pdf
description: "将各类文件批量转换为 PDF 格式。支持 Office 文档(Word/Excel/PowerPoint)、图片(JPG/PNG/BMP/GIF/WebP/TIFF)、HTML 网页、Markdown 文件和纯文本文件。当用户要求将文件转为 PDF、导出 PDF、把图片合并成 PDF、或批量转换文档格式时触发此技能。This skill should be used when users ask to convert files to PDF, export to PDF, merge images into a PDF, or batch convert documents to PDF format."
agent_created: trueFile to PDF
Overview
将多种格式的文件转换为 PDF。支持 Office 文档、图片、HTML、Markdown 和纯文本,支持单文件和批量转换,支持将多张图片合并为单个 PDF 文件。
支持的文件格式
| 类别 | 扩展名 | 转换工具 |
|---|---|---|
| Office 文档 | .docx .doc .xlsx .xls .pptx .ppt .odt .ods .odp .rtf .csv | LibreOffice |
| 图片 | .jpg .jpeg .png .bmp .gif .webp .tiff .tif | Pillow |
| HTML | .html .htm | LibreOffice |
| Markdown | .md .markdown | markdown + LibreOffice |
| 纯文本 | .txt | LibreOffice (via HTML) |
依赖项
LibreOffice(必需——Office/HTML/Markdown/文本转换)
用于转换 Office 文档、HTML、Markdown 和纯文本。安装地址:https://www.libreoffice.org/
自动检测路径:
- Windows:
C:\Program Files\LibreOffice\program\soffice.exe - macOS:
/Applications/LibreOffice.app/Contents/MacOS/soffice - Linux/PATH:
soffice或libreoffice
可通过 --soffice <path> 参数指定自定义路径。
Pillow(图片转换)
用于将图片转为 PDF。如未安装,脚本会自动通过 pip 安装到 managed venv。
markdown(Markdown 转换)
用于将 Markdown 转为 HTML。如未安装,脚本会自动通过 pip 安装。
使用方法
运行时环境
使用 managed Python 运行脚本。脚本会自动将 managed venv 的 site-packages 路径注入 sys.path,因此 Pillow 和 markdown 库可直接使用。
# Managed Python 路径(Windows)
C:\Users\fenhua\.workbuddy\binaries\python\versions\3.13.12\python.exe
脚本位置
scripts/convert_to_pdf.py
基本命令
# 转换单个文件
python scripts/convert_to_pdf.py input.docx
# 转换多个文件
python scripts/convert_to_pdf.py file1.docx file2.xlsx file3.pptx
# 转换整个目录(不递归)
python scripts/convert_to_pdf.py ./documents/
# 递归转换目录
python scripts/convert_to_pdf.py ./documents/ --recursive
# 指定输出目录
python scripts/convert_to_pdf.py input.docx --output ./pdf_output/
# 多张图片合并为一个 PDF
python scripts/convert_to_pdf.py ./images/ --merge
# 覆盖已有 PDF 文件
python scripts/convert_to_pdf.py input.docx --overwrite
# 指定 LibreOffice 路径
python scripts/convert_to_pdf.py input.docx --soffice "C:\Program Files\LibreOffice\program\soffice.exe"
参数说明
| 参数 | 简写 | 说明 |
|---|---|---|
inputs |
- | 要转换的文件或目录路径(至少一个) |
--output |
-o |
输出目录(默认与源文件同目录) |
--merge |
-m |
将多张图片合并为单个 PDF |
--recursive |
-r |
递归处理子目录 |
--overwrite |
- | 覆盖已有的 PDF 文件 |
--soffice |
- | 自定义 LibreOffice 可执行文件路径 |
退出码
| 退出码 | 含义 |
|---|---|
| 0 | 所有文件转换成功 |
| 1 | 部分文件转换失败 |
| 2 | 未找到支持的文件 |
转换流程
- 检测文件类型:根据文件扩展名确定转换方式
- 图片:使用 Pillow 直接转换为 PDF(支持 RGBA 透明背景处理)
- Office 文档/HTML:通过 LibreOffice headless 模式转换
- Markdown:先用 Python markdown 库转为 HTML(带样式),再用 LibreOffice 转 PDF
- 纯文本:转为带样式的 HTML,再用 LibreOffice 转 PDF
- 批量模式:遍历目录,逐一转换,最后汇总结果
注意事项
- 图片转换不需要 LibreOffice,仅依赖 Pillow
- Office 文档转换时 LibreOffice 会以 headless 模式运行,不弹出界面
- Markdown 转换会自动添加中文字体样式和代码高亮样式
- 合并图片时按文件名排序
- 默认不覆盖已有 PDF,需加
--overwrite参数强制覆盖 - 脚本使用临时目录处理转换中间文件,完成后自动清理
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 高价值高频刚需工具,直接解决用户日常文档格式转换痛点
- 支持 Office/图片/HTML/Markdown/文本等主流格式,覆盖场景全面
- 支持批量处理与图片合并为单个 PDF,具备实用扩展性
Highlights
- 触发词精准完整,中英文描述覆盖多种变体
- 边界清晰,不易与其他 Skill 重叠
Highlights
- 结构清晰完整:Overview → 支持格式 → 依赖项 → 使用方法 → 转换流程 → 注意事项
- 包含端到端示例与完整参数说明,frontmatter 规范
Areas to improve
-
未显式处理 LibreOffice 未安装的错误提示 Reported severity: Minor
脚本依赖 LibreOffice 进行 Office/HTML/Markdown/文本转换,但未在文档中说明未安装时的错误处理方式
Recommendation: 建议在注意事项或转换流程中增加 LibreOffice 未安装时的友好错误提示与安装引导
Highlights
- 工具来源明确(LibreOffice/Pillow/markdown),参数说明完整
- 有退出码机制区分成功/部分失败/无文件,自动处理依赖安装
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- www.libreoffice.org
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Not specified in the source documentation.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.