« Populaire (タイピスト!) | トップページ | The Intern(マイ・インターン) »

[AppleScript]アートボードサイズでカスタム用紙設定する

広告送稿もAiネイティブPDFになったし
デザイナーさんはディスティラーPDFを何に使っているのか?と思いき
よくある答えが、『サイズを小さくしたい』ってのが多い
メールに添付出来るサイズに…って事らしい。
今の現場はクラウドストレージがあるので
メールに添付する機会も以前より減っているようで
ディスティラーPDFの出番は、昔のように多くは無いのが今


デザイナーさんには、色々な小物をたのまれますが
何で?何のため?ってのも
たまに、あります。
でも
本人気がすむのでしょうから、作って上げる事が多い


『余白0』(ここで言う余白0は『用紙サイズ』と『印刷可能エリア』が同サイズの事)のPDFを
ディスティラーPDFで作るには
余白0のPPDが必要で、多くは『DS TRUEFLOW』か『Adobe PDF 9.0 J』を使って
http://force4u.cocolog-nifty.com/skywalker/2016/01/applescriptsps-.html
カスタムで用紙サイズを指定するわけです

20161224_194321



何で?かしらんが(一応理由は聞いたが、要点を得なかった…苦笑)
ドライバーで指定で印刷したい(PS吐きたい)んだそうだ…

Website_image00281227_223752


結果的には
葉書サイズのアートボードの場合
↓こんな風に、カスタム用紙サイズとして登録されます。

20161224_194748


(*

Ai2CustompapersSize

全面にあるアートボートサイズで
プリンターの用紙設定をします。
(塗りたしサイズではありません)

20161224 初回作成
*)




---余白(設定項目)
set theLeft to "0" as text
set theRight to "0" as text
set theTop to "0" as text
set theBottom to "0" as text
---初期値(設定しなくてもOK
set theId to "" as text
set theName to "" as text
---初期値(ここは設定しなくてもOK
set thePrinter to " " as text
set theCustom to "TRUE" as text
set theWidth to "" as text
set theHeight to "" as text

----ユーザードメインの初期設定フォルダまでのパスを取得
set theUserPrefDirName to (path to preferences folder from user domain) as text
---バックアップ用のディレクトリを作成
try
make new folder at theUserPrefDirName with properties {name:"com.apple.print.custompapers.backup"}
end try
-----ファイル名やらディレクトリ名やら
set thePrefFile to (theUserPrefDirName & "com.apple.print.custompapers.plist") as text
set theBackupDir to (theUserPrefDirName & "com.apple.print.custompapers.backup") as text
set theBackupFileName to (theBackupDir & ":com.apple.print.custompapers.plist") as text
---日付け時間取得
set theTime to (do shell script "date '+%Y%m%d_%k%M%S'") as text
set theNewFileName to ("com.apple.print.custompapers.plist." & theTime & ".plist") as text

----ファイルをコピーしてからファイル名を変更する
tell application "Finder"
try
copy file thePrefFile to folder theBackupDir
delay 1
set the name of file theBackupFileName to theNewFileName
end try
end tell
---イラストレーター
tell application "Adobe Illustrator"
activate
---開いているドキュメント
tell current document
---全面のアードボード
tell artboard 1
---プロパティを取得
set theProp to properties
---アートボードを取得
set theRect to (artboard rectangle of theProp) as list

end tell
end tell
end tell
---各値を取得
set theWl to (item 1 of theRect) as number
set theHt to (item 2 of theRect) as number
set theWr to (item 3 of theRect) as number
set theHb to (item 4 of theRect) as number
---幅と高さを求める
set theWidthPx to theWl - theWr as number
set theHightPx to theHt - theHb as number
---Absolute value絶対値にする
if theWidthPx < 0 then set theWidthPx to -theWidthPx
if theHightPx < 0 then set theHightPx to -theHightPx
---幅と高さをミリに換算
set theWidthMM to (((theWidthPx / 72) * 25.4) as integer) as text
set theHeightMM to (((theHightPx / 72) * 25.4) as integer) as text
---書き込み用の値にする
set theWidth to (theWidthPx) as text
set theHeight to (theHightPx) as text
---書き込み用の値にする(タイトル用にミリ表記)
set theName to (theWidthMM & "x" & theHeightMM) as text
set theId to (theWidthMM & "x" & theHeightMM) as text

--------defaults write com.apple.print.custompapers
-----theName
set theNameCom to "defaults write com.apple.print.custompapers \"" & theName & "\" -dict-add name -string \"" & theName & "\"" as text
set theNameCom to doReplace(theNameCom, "\"\"", "\"")
do shell script theNameCom

-----theId
set theIdCom to "defaults write com.apple.print.custompapers \"" & theName & "\" -dict-add id -string \"" & theId & "\"" as text
set theIdCom to doReplace(theIdCom, "\"\"", "\"")
do shell script theIdCom

-----Printer
set thePrinterCom to "defaults write com.apple.print.custompapers \"" & theName & "\" -dict-add printer -string \"" & thePrinter & "\"" as text
set thePrinterCom to doReplace(thePrinterCom, "\"\"", "\"")
do shell script thePrinterCom

-----Custom
set theCustomCom to "defaults write com.apple.print.custompapers \"" & theName & "\" -dict-add custom -bool " & theCustom & "" as text
set theCustomCom to doReplace(theCustomCom, "\"\"", "\"")
do shell script theCustomCom

-----height
set theHeightCom to "defaults write com.apple.print.custompapers \"" & theName & "\" -dict-add height -float " & theHeight & "" as text
set theHeightCom to doReplace(theHeightCom, "\"\"", "\"")
do shell script theHeightCom

-----width
set theWidthCom to "defaults write com.apple.print.custompapers \"" & theName & "\" -dict-add width -float " & theWidth & "" as text
set theWidthCom to doReplace(theWidthCom, "\"\"", "\"")
do shell script theWidthCom

-----top
set theTopCom to "defaults write com.apple.print.custompapers \"" & theName & "\" -dict-add top -float " & theTop & "" as text
set theTopCom to doReplace(theTopCom, "\"\"", "\"")
do shell script theTopCom

-----bottom
set theBottomCom to "defaults write com.apple.print.custompapers \"" & theName & "\" -dict-add bottom -float " & theBottom & "" as text
set theBottomCom to doReplace(theBottomCom, "\"\"", "\"")
do shell script theBottomCom

-----left
set theLeftCom to "defaults write com.apple.print.custompapers \"" & theName & "\" -dict-add left -float " & theLeft & "" as text
set theLeftCom to doReplace(theLeftCom, "\"\"", "\"")
do shell script theLeftCom

-----right
set theRightCom to "defaults write com.apple.print.custompapers \"" & theName & "\" -dict-add right -float " & theRight & "" as text
set theRightCom to doReplace(theRightCom, "\"\"", "\"")
do shell script theRightCom

return "Done"

--------------文字の置き換えサブルーチン
to doReplace(theText, theOrgStr, theNewStr)
set theOldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to theOrgStr
set theTmpList to every text item of theText
set AppleScript's text item delimiters to theNewStr
set theReplaceStr to theTmpList as text
set AppleScript's text item delimiters to theOldDelim
return theReplaceStr
end doReplace


インストール先はCS6ならこちら

Website_image00281227_224809

ここから実行です

Website_image00281227_224822

細かい
エラー制御していません。

「Ai2CustompapersSize.zip」をダウンロード

|

« Populaire (タイピスト!) | トップページ | The Intern(マイ・インターン) »

AdobeIllustrator」カテゴリの記事