on run
set theDefLoc to (path to desktop from user domain) as alias
set theFileType to "public.pdf,com.adobe.pdf" as text
set AppleScript's text item delimiters to {","}
set theFileTypeList to every text item of theFileType
set theWithPrompt to theFileType & "PDF\nをえらんでください\n"
set theWithPromptMes to "PDFフォームファイルを選んでください"
open (choose file default location theDefLoc ¬
with prompt theWithPrompt & theWithPromptMes ¬
of type theFileTypeList ¬
invisibles true ¬
with multiple selections allowed without showing package contents)
end run
on open objOpenFile
tell application "TextEdit" to activate
tell application "Adobe Acrobat" to activate
delay 5
set theFldNUM to "" as text
set theTitleText to "" as text
set theValeText to "" as text
set theTitleChk to 0 as integer
set theFileCnt to 0 as integer
repeat with objFiles in objOpenFile
set theFldCntNUM to 0 as integer
set theTemFilePath to POSIX path of objFiles as text
tell application "Adobe Acrobat"
activate
do script "app.openDoc(\"" & theTemFilePath & "\");"
delay 0.5
if theTitleChk = 0 then
do script "var theFildNo = this.numFields"
set theFldNUM to (do script "theFildNo") as text
repeat theFldNUM times
do script "var theFildTitle = this.getNthFieldName(" & theFldCntNUM & ")"
set theFildTitleText to (do script "theFildTitle") as text
set theTitleText to ("" & theTitleText & theFildTitleText & "\t") as text
set theFldCntNUM to (theFldCntNUM + 1)
end repeat
end if
set theTitleChk to (theTitleChk + 1) as integer
set theFldCntNUM to 1 as integer
set AppleScript's text item delimiters to {"\t"}
set listTitleText to (every text item of theTitleText) as list
set AppleScript's text item delimiters to {""}
set theFileCnt to (theFileCnt + 1) as integer
set theValeText to ("" & theValeText & theFileCnt & "\t") as text
repeat theFldNUM times
set theFormValue to (item theFldCntNUM of listTitleText) as text
do script "var theFormValeText = this.getField(\"" & theFormValue & "\").value;"
set theFildValeText to (do script "theFormValeText") as text
set theValeText to ("" & theValeText & theFildValeText & "\t") as text
set theFldCntNUM to (theFldCntNUM + 1)
end repeat
set theValeText to ("" & theValeText & "\n") as text
do script "closeDoc();"
end tell
end repeat
set theTitleText to ("No\t" & theTitleText & "\n") as text
set theValeText to (theTitleText & theValeText) as text
set theDesktopUnixPath to POSIX path of (path to desktop folder from user domain) as text
set aliasDesktop to (path to desktop folder from user domain as alias) as text
set theSaveFile to (aliasDesktop & "フォームデータ.txt") as text
set theSaveFileName to ("フォームデータ.txt") as text
tell application "Finder"
set theFolder to ((aliasDesktop) as alias)
try
make new file at aliasDesktop with properties {name:(theSaveFileName)}
end try
set theOutPutFile to (((aliasDesktop) as text) & ((theSaveFileName) as text)) as alias
end tell
tell application "TextEdit"
open theOutPutFile
tell document 1
set its text to theValeText
end tell
save document 1
end tell
end open