说明
业务需求,需要在手机端(web)显示ppt或者word文档,第一版考虑使用PDF显示,可在手机端使用js直接解析pdf性能糟糕,查看或者翻页不够流畅,立马考虑使用图片来代替PDF。
1.macOS中自动化批量将PPT文档导出为PDF
2.macOS中自动化批量将PDF文档导出为图片
前置条件
电脑上必须安装 Microsoft Word软件
操作步骤
- 打开自动操作,新建『工作流程』
- 将『操作>文件和文件夹>获取指定的访达项目』拖到操作区域,或者直接选择一个Word文件拖动到操作区域。
- 将『操作>实用工具>运行AppleScript』拖到操作区域,复制一下代码
property theList : {"doc", "docx"}on run {input, parameters}set output to {}tell application "Microsoft Word" to set theOldDefaultPath to get default file path file path type documents pathrepeat with x in inputtryset theDoc to contents of xtell application "Finder"set theFilePath to container of theDoc as textset ext to name extension of theDocif ext is in theList thenset theName to name of theDoccopy length of theName to lcopy length of ext to exlset n to l - exl - 1copy characters 1 through n of theName as string to theFilenameset theFilename to theFilename & ".pdf"tell application "Microsoft Word"set default file path file path type documents path path theFilePathopen theDocset theActiveDoc to the active documentsave as theActiveDoc file format format PDF file name theFilenamecopy (POSIX path of (theFilePath & theFilename as string)) to end of outputclose theActiveDocend tellend ifend tellend tryend repeattell application "Microsoft Word" to set default file path file path type documents path path theOldDefaultPathreturn outputend run
- 脚本问题,每次多个个文件导出时第一个总不能成功导出。
