ClawHub
SkillsPluginsOfficialDocsSupport
K
Skillsdocx2pdf

docx2pdf

Dong Zhao@zd200572
在 Windows 上用 LibreOffice 的 soffice.exe 无头模式,批量把当前目录下的 .doc / .docx 转成 .pdf。不依赖 Microsoft Word 安装,纯命令行,适合一次性批量处理。 无需 Office 许可证,跨 Windows 版本可用。
Install in OpenClawRequires OpenClaw desktop app
Security check
Clean
Version
1.0.0
Updated
Oct 10, 2026
License
MIT-0

Latest: v1.0.0

  • 首次发布,版本 1.0.0
  • 支持在 Windows 上无需 Microsoft Word,仅用 LibreOffice 的 soffice.exe 命令行,将当前目录下的 .doc/.docx 批量转换为 PDF
  • 适合 PowerShell 环境,支持通配符批量处理,支持输出目录自定义
  • 无需 Office 许可证,支持 Windows 7 及以上版本
  • 提供常见命令、变体、常见问题与踩坑经验,便于部署和故障排查
Automation
#pdf

docx2pdf — Word 批量转 PDF

不依赖 Microsoft Word,用 LibreOffice 在命令行批量把 .doc / .docx 转 .pdf。

一行命令(最常用)

powershell
& 'C:\Program Files\LibreOffice\program\soffice.exe' --headless --invisible --convert-to pdf --outdir ./ *.doc *.docx

如果你的 LibreOffice 装在别的位置,把路径换成你的;或者先设环境变量:

powershell
$env:SOFFICE = 'D:\Program Files\LibreOffice\program\soffice.exe'
& $env:SOFFICE --headless --invisible --convert-to pdf --outdir ./ *.doc *.docx

命令拆解

段作用
& '...soffice.exe'PowerShell 调用带空格路径的可执行文件,必须用 &(调用运算符)
--headless --invisible无 UI、无弹窗;两个都带,缺一个都可能挂起
--convert-to pdf输出格式;也可写 pdf:writer_pdf_Export 显式指定导出器
--outdir ./输出目录,./ = 当前目录;改 output_folder 输出到子目录
*.doc *.docxPowerShell 通配符展开后逐个传给 soffice(soffice 本身不解析通配符)

常见变体

powershell
# 只转 .docx
& $env:SOFFICE --headless --invisible --convert-to pdf --outdir ./ *.docx

# 输出到子目录
& $env:SOFFICE --headless --invisible --convert-to pdf --outdir ./pdf_out *.doc *.docx

# 递归子目录(PowerShell 展开)
Get-ChildItem -Recurse -Include *.doc,*.docx | ForEach-Object {
  & $env:SOFFICE --headless --invisible --convert-to pdf --outdir $_.DirectoryName $_.FullName
}

# 找到 soffice 真实路径(多版本共存时)
Get-ChildItem 'C:\Program Files','D:\Program Files' -Recurse -Filter soffice.exe -ErrorAction SilentlyContinue |
  Select-Object -ExpandProperty FullName

踩过的坑(来自真实历史)

  1. 直接 'path\soffice.exe' args → PowerShell 把字符串当字符串,不执行。必须 & 'path' args。
  2. 传 ./ 或 .\* → soffice 把目录当文件,转换失败。要靠 shell 通配符展开具体文件列表。
  3. 路径里 Program Fil、Program\ Fil 这种截断/转义错乱 → 整段用单引号包起来,别自己拆。
  4. 连续跑批第二次报 already running →
    powershell
    Get-Process soffice* -ErrorAction SilentlyContinue | Stop-Process -Force
    Start-Sleep -Seconds 2
    
  5. .pdf 已存在会被静默覆盖,源文件不会有事,但旧 PDF 不会提示。
  6. 路径里没有 soffice.exe → 用上面 Get-ChildItem 找一下真实位置;LibreOffice 32 位默认在 C:\Program Files (x86)\LibreOffice\program\soffice.exe。

故障排查

症状原因解决
命令没反应缺 & 调用运算符& 'path\to\soffice.exe' args
报 "is not recognized"路径错误或没引号整段路径用单引号包起来
报 "source file could not be loaded"传了目录而非具体文件用 *.doc *.docx 展开,别传 ./
报 "already running"上次 soffice.bin 没退Stop-Process -Name soffice* -Force
输出 PDF 排版错乱Word 用了 LibreOffice 不支持的功能用 Word 自己"另存为 PDF",或换 PDF 导出器参数

什么时候用这个 skill

  • 没有安装 Microsoft Word,或不想开 Word 批量另存
  • 几十上百个 doc/docx 要一次性出 PDF
  • 需要放进脚本 / 自动化流水线
  • 跨 Windows 机器跑,不想装 Office

要保真排版(尤其有修订、SmartArt、嵌入 Excel 表)时,优先用 Word 自己的"另存为 PDF"。

License

MIT,随便拿去用。

Related skills

More in Automation
ClawHub

Skills and plugins for OpenClaw agents. Part of the wider OpenClaw ecosystem.

Explore docs

SkillsPluginsOfficialAudits

Publish SkillPublish PluginCreate org

OverviewOpenClawDocsBlog

SupportGitHubDiscord

Built alongside the OpenClaw ecosystem

LobsterCrabboxClickClackCrabfleetOctopoolClawSweeperagent-skillsdiscrawlgitcrawlslacrawlnotcrawltelecrawlgraincrawlcrawlkitcrawlbaracpxmcporterTachikomaclawpatchclawbenchPeekaboocookbookplugin-inspectorwacrawlcrabpotAll projectsLobsterCrabboxClickClackCrabfleetOctopoolClawSweeperagent-skillsdiscrawlgitcrawlslacrawlnotcrawltelecrawlgraincrawlcrawlkitcrawlbaracpxmcporterTachikomaclawpatchclawbenchPeekaboocookbookplugin-inspectorwacrawlcrabpotAll projects

© 2026 OpenClaw Foundation

Privacy policy·Status·Deployed on Vercel·Powered by Convex

....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals