使用macOS的Preview时,有时候想要并排显示同一个pdf,最简单的就是使用File->Duplicate来创建一个副本,关闭副本窗口时选择Delete。缺点就是会创建一个临时文件。
另一种方法就是用”open -n”打开需要预览的pdf,这样会创建Preview的另一个实例。这要求我们获取当前文件的路径,可以通过Apple Script来实现。
if application "Preview" is running then
tell application "Preview"
set theDocs to documents
if (count of theDocs) > 0 then
set thePath to path of item 1 of theDocs
return thePath
else
return ""
end if
end tell
else
return ""
end if
以上代码仅当Preview运行时返回当前文档的路径。
有了上述脚本,我们可以
- 创建一个Shortcuts来运行”open -n”命令,获取当前文档并打开新的Preview实例预览该pdf。
- 为shortcut设置一个全局的快捷键,方便快速调用。
使用”open -n”有一个小问题,就是当修改其中一个pdf保存后,另一个实例也会重新加载pdf,导致当前浏览的页面跳转到其他页面。