在 Mac OS X 中将一批 Word 文件转换为 PDF

Joe*_*nin 9 pdf microsoft-word macos

假设我在一个文件夹中有几个 Word 文件。有没有办法从这些文件中生成一批 PDF?

n8h*_*rie 8

One option using the command line would be to use pandoc (which requires LaTeX for PDF generation).

  1. Install pandoc and LaTeX. Because LaTeX is so big, I installed BasicTeX as recommended in the pandoc docs. With Homebrew and Homebrew Cask: brew install pandoc && brew install --cask basictex
  2. Make sure the Word files are in .docx format. If they are in .doc format, you can convert them with OS X's built-in textutil: textutil -convert docx *.doc
  3. On El Capitan you have to add the texbin utilities to your PATH: export PATH=/Library/TeX/texbin:"$PATH"
  4. Convert: pandoc -o myfile.pdf myfile.docx

因为您的问题是关于批量转换多个文件,所以您可以轻松地将其放入循环中:

#! /bin/bash
for file in *.doc; do
  textutil -convert docx "$file"

  # Account for the new `x` in `docx`
  pandoc -o "${file%doc}pdf" "${file}x"
done
Run Code Online (Sandbox Code Playgroud)


Al *_*hri 7

您可以使用docx2pdf命令行实用程序在 macOS(或 Windows)上将 docx 批量转换为 pdf。它使用 Microsoft Word 的 API 直接转换为 PDF,创建完美的副本。它在 macOS 中使用 JXA(Javscript for Automation,基本上是 JS 中的 AppleScript)和 Windows 中的 win32com。

pip install docx2pdf
docx2pdf myfolder/
Run Code Online (Sandbox Code Playgroud)

免责声明:我在努力寻找跨平台解决方案以零格式将 docx 转换为 pdf 后编写了此工具,因为它直接使用 Microsoft Word。https://github.com/AlJohri/docx2pdf

  • 今天刚刚在 macOS Catalina 10.15.5 中尝试过。Word 中存在一些弹出消息,需要单击才能使其正常工作,但一旦我这样做了,它就像一个魅力。 (4认同)

mol*_*gar 4

如果您安装了 MS Word(或任何其他可以打开 MS Word 文件的应用程序),则可以使用 Automator。以下是有关如何根据您的需求进行设置的分步指南:http://aseriesoftubes.com/articles/how-to-batch-convert-doc-files-to-pdf-format-using-mac-osx -自动化装置/

整个过程简要概述:

  1. 打开自动化器
  2. 创建新的工作流程
  3. library左侧面板中,选择Files & Folders然后双击Get Specified Finder Items
  4. 添加所有要转换的文件
  5. library现在从面板中选择Documents,然后双击Convert Format of Word Documents
  6. 从下拉菜单中选择Portable Document Format (PDF)
  7. 最后,单击Run按钮,它将转换所有文件并将它们保存在原始Word文件所在的同一文件夹中。

  • Office 2016 已放弃 Automator 支持。这可能是您看不到该选项的原因吗? (5认同)
  • 我在 OS X El Capitan 的 Automator 中没有看到此选项(“转换 Word 文档格式”)。它被删除了吗? (3认同)