[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(DTPtechNote:938) [AS-InDesign CS] PDFセーブするドロップレット
です。
まともにエラー処理してません。あしからず^^。
ちゃんとしたら表に出すべきなのかな?
on open of theFiles
--書き出しPDFスタイルを選択する
tell application "InDesign CS_J"
set pdf_export_presets to name of PDF export presets
set pdf_export_presets to (choose from list pdf_export_presets with prompt ("PDF書き出しプリセットを選んでください") as Unicode text) as Unicode text
end tell
tell application "Finder"
repeat with i in theFiles
set indd_file to contents of i
set my_folder to (folder of i) as Unicode text
set my_name to (name of i) as Unicode text
if my_name ends with ".indd" then
set save_PDF_path to my_folder & my replace(my_name, ".indd", ".pdf")
else
set save_PDF_path to my_folder & my_name & ".pdf"
end if
try
my doit(indd_file, save_PDF_path, pdf_export_presets)
on error errMsg number errNum
my my_error("誤りが起きました;" & my_name & return & "処理を中断しますか?" & return & errMsg & return & errNum, false)
end try
end repeat
say "Work was finished. " & (length of theFiles) & " files were processed."
end tell
end open
--ファイルをひらいて、PDFをsaveする
to doit(indd_file, save_PDF_path, pdf_export_presets)
tell application "InDesign CS_J"
open indd_file
export document 1 format PDF type to save_PDF_path using PDF export preset pdf_export_presets
close document 1 saving no
end tell
end doit
----------------------------------●置換
to replace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end replace
----------------------------------●エラー処理
on my_error(err_str, my_stop)
set err_str to err_str as Unicode text
if my_stop then
set my_stop to {"中止"}
else
set my_stop to {"中止", "続行"}
end if
tell application "InDesign CS_J"
activate
beep
set ANS to button returned of (display dialog err_str buttons my_stop with icon stop) --警告ダイアログ出してストップ
if ANS is "中止" then error number -128
end tell
end my_error