2016-12-26 193 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 
相關問題