使用 Applescript 将 PDF 文件转换为 CSV、Excel 或 Numbers 格式

Convert a PDF file into CSV, Excel or Numbers format using Applescript

每个月我都会得到我的银行存款余额,基本上只是 table。为了更好地了解我的开支,我想将此列表导出到 Numbers (iWork) 文档中。我希望使用 Applescript 来自动执行此过程:)

有谁知道如何将 PDF(文本类型)列表转换为 CSV、Excel 或数字?

如果您尝试过任何代码,很高兴看到。此外,如果不了解您正在使用的 pdf 类型如何经历这种过程,就很难知道结果可能是什么。考虑到这一点,这就是我正在谈论的那种过程......

我建议下载并使用漂亮的可编写脚本的 Skim pdf 应用程序 (http://skim-app.sourceforge.net/)。预览太有限了。基本的 Adob​​e reader 可能具有足够的功能,但是,好吧,我是 Skim 的粉丝。 CSV 文件基本上只是文本,所以这应该可以工作,但同样,不知道您的文本格式如何,我无法确定结果。如果您分享示例,我很乐意进行编辑。以下内容适用于纯文本 pdf:

tell application "Finder" to set dt to desktop as string
tell application "Skim"
    set docName to name of document 1
    set baseName to text 1 thru ((offset of "." in docName) - 1) of docName
    set docText to text of document 1
    set filePath to (dt & baseName & ".csv")
    set myFile to open for access filePath with write permission
    write docText to myFile --as «class utf8»--depending on results, you may need this last part. test
    close access myFile
end tell
tell application "Numbers"
    activate -- I got weird buggy results not activating (or at least launching) first.
    open alias filePath
end tell