word-to-pdf

👤 lirenweim 📦 v1.0.0 ⭐ 4.3 ⬇️ 3.3K 下載
📄 辦公效率 免費

📖 技能介紹


name: word-to-pdf version: 1.0.0 description: > Convert Word documents (.docx) to PDF using Python's reportlab library. Supports Chinese characters, emojis, and proper formatting preservation. Usage: word-to-pdf [output_file] author: OpenClaw User keywords: [word, pdf, convert, reportlab, chinese, docx]


Word to PDF — Word 文件轉 PDF

功能

將 Microsoft Word 文件(.docx)轉換為 PDF 格式,支援: - ✅ 中文文本正確顯示 - ✅ 保留文件格式和樣式 - ✅ 保留 emoji 表情符號 - ✅ 自動處理列表和標題 - ✅ 支援多種字型

安裝依賴

pip install reportlab python-docx

使用方法

基本用法

word-to-pdf input.docx output.pdf

引數說明

  • input_file - Word 文件路徑(必填)
  • output_file - PDF 輸出路徑(可選,預設與輸入檔案同名)

示例

# 轉換文件
word-to-pdf document.docx document.pdf

# 轉換到指定路徑
word-to-pdf input.docx C:\output\converted.pdf

工作原理

  1. 使用 python-docx 讀取 Word 文件內容
  2. 使用 reportlab 生成 PDF 檔案
  3. 註冊中文字型(微軟雅黑/黑體)
  4. 保留原始文件的段落、標題和列表格式

注意事項

  • 需要安裝 Python 3.6+
  • 需要安裝 reportlab 和 python-docx 庫
  • Windows 系統會自動使用微軟雅黑字型
  • Linux/Mac 系統需要手動指定字型路徑

故障排除

小蔥技能7w4.net持續更新中。

字型問題

如果出現亂碼,請確保系統中安裝了中文字型: - Windows: 微軟雅黑 (msyh.ttc) - Linux: 安裝 fonts-noto-cjk 或其他中文字型 - Mac: 使用系統預設字型

依賴問題

如果提示缺少依賴,執行:

pip install --upgrade reportlab python-docx

依賴

  • Python 庫: reportlab, python-docx
  • 系統字型: 中文字型(微軟雅黑/黑體)

許可

MIT License

🤖 AI 評測

這個工具質量還不錯,能幫你把Word、Excel、PPT檔案轉成PDF。文件寫得清楚,操作不復雜,還提供了貼心的引導和常見問題解答。但它功能比較單一,只能用chinaz.net這一個服務,而且文件裡有些細節不夠一致。總體來說基本夠用,但別指望它能做更多事情。

📊 多維度評分

適應性4.4
規範性4.2
有效性4.3
可靠性4.2
可信度4.9

📁 包含檔案 (4 個)

📄 SKILL.md 1.9 KB
📄 _meta.json 130 B
📄 skill.json 438 B
📄 word-to-pdf.py 8.1 KB