Mac 使用 Microsoft Word 批量将 DOCX 转 PDF 并保持原排版

作者:袖梨 2026-07-17

Mac 使用 Microsoft Word 批量将 DOCX 转 PDF(保持原排版)

之前尝试过使用 WPS 和 LibreOffice 批量转换 DOCX 为 PDF,但发现导出的 PDF 存在页边距变大、上下留白增加、分页错乱等问题。

如果 Mac 已安装 Microsoft Word,可以直接通过 AppleScript 调用 Word 导出 PDF,生成效果与 Word 手动导出基本一致。

单个文件转换

osascript <<'EOF'tell application "Microsoft Word"open POSIX file "/Users/mac/Downloads/1/1.docx"set d to active documentsave as d file name "/Users/mac/Downloads/1/1.pdf" file format format PDFclose d saving noend tellEOF

批量转换整个目录

例如需要转换:

/Users/mac/Downloads/1

目录下所有 .docx 文件:

DIR="/Users/mac/Downloads/1"for f in "$DIR"/*.docx; do[ -f "$f" ] || continuepdf="${f%.docx}.pdf"osascript <<EOFtell application "Microsoft Word"open POSIX file "$f"set d to active documentsave as d file name "$pdf" file format format PDFclose d saving noend tellEOFecho "Converted: $(basename "$f")"done

转换后:

1.docx->1.pdf2.docx->2.pdf3.docx->3.pdf

PDF 会保存在原文件所在目录。

适用场景

  • 合同
  • 标书
  • 论文
  • 公司模板
  • 对 PDF 排版一致性要求较高的文档

相比 WPS、LibreOffice 转换,直接调用 Microsoft Word 导出的 PDF 更能保持原始排版。

相关文章

精彩推荐