[Illustrator][AppleScript]レイヤーごとにJPEGを書き出すのPDF版も書いてみた。
<仕様>
●Illustratorに登録されているPDFプリセットを選択して、そのプリセットでPDFを書き出す
(基本AdobeCSシリーズ共有のプリセットが使用できるけど、InDesignとはPDFの書き出し設定が違うので要注意)
●どのPDFにも必要なオブジェクトは表示レイヤーに入れてある
●レイヤーごとに必要なオブジェクトが格納されている
●レイヤーの表示のオン/オフで書き出すPDFを決める
●PDFの名前はレイヤー名から取得
●エラー処理はすっとばす
デモ動画はそのうち。
tell application "Adobe Illustrator"set pPdfPresets to PDF presets
tell application "Finder"
set choosePreset to choose from list pPdfPresets OK button name "PDF書き出し" with title "プリセットを選択してください"
copy the result as list to {the pPdfPresets}
set PDFpreset to pPdfPresets as Unicode text
end tell
activate
tell document 1
--保存場所を決める
set filePath to choose folder with prompt "保存するフォルダを選択してください" as string
--ここからIllustratorの処理
tell application "Adobe Illustrator"
activate
set myDoc to document 1
tell myDoc
--非表示レイヤーをリスト化して変数へ
set visibleFalseLayer_list to every layer whose visible is false
end tell
--非表示レイヤーの数だけ繰り返す
repeat with a from 1 to count of visibleFalseLayer_list
tell myDoc
set currentLayer to item a of visibleFalseLayer_list --処理用に代入
set visible of currentLayer to true --レイヤーを表示状態に
set myLayerName to name of currentLayer
set newFilePath to filePath & myLayerName & ".jpg" as string --保存ファイル名を代入
end tell
--PDFで別名で保存
save myDoc in file newFilePath as pdf with options {class:PDF save options, PDF preset:PDFpreset}
tell myDoc
set visible of currentLayer to false --再度非表示にする
end tell
end repeat
tell myDoc
close saving no
end tell
end tell
activate
display dialog ((count of visibleFalseLayer_list) as string) & "ファイル書き出しました"
end tell
end tell
ダウンロードできるようにしました。