use framework "Foundation"
use framework "Quartz"
use scripting additions
on getTextFromPDF:posixPath
set theURL to current application's class "NSURL"'s fileURLWithPath:posixPath
set thePDF to current application's PDFDocument's alloc()'s initWithURL:theURL
return (thePDF's |string|()) as text
end getTextFromPDF:
#=====
on decoupe(t, d)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe
#=====
its getTextFromPDF:(POSIX path of (choose file of type {"pdf"}))
my decoupe(result, "character")
set nbOccurences to (count result) - 1