2016-12-26 181 views
0

每个月我都会得到我的银行余额,它基本上只是一张表。为了更好地了解我的开支,我想将此列表导出到Numbers(iWork)文档中。我希望使用Applescript,所以可以自动执行此过程:)使用Applescript将PDF文件转换为CSV,Excel或Numbers格式

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

回答

1

如果您已经尝试过任何代码,很高兴看到。另外,如果没有看到你所使用的pdf类型是如何通过这种过程的话,很难知道结果会是什么。考虑到这一点,这里是我谈论的那种过程...

我会建议下载和使用漂亮的脚本能脱脂pdf应用程序(http://skim-app.sourceforge.net/)。预览太有限。基本的Adobe阅读器可能具有足够的功能,但是,我是一个脱脂粉丝。 一个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 
相关问题