« [メモ]用紙サイズ(ポイント換算) | トップページ | [Jsx]上下集約ページを単一連続ページに変換 »

[com.apple.print.custompapers.plist]カスタム用紙サイズを設定する

【スクリプトエディタで開く】

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
# 
#
#                       com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()
set ocidTrue to (refMe's NSNumber's numberWithBool:true)


####設定ファイルのパス
set ocidLibrariesPathURLArray to (appFileManager's URLsForDirectory:(refMe's NSAllLibrariesDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibrariesPathURL to item 1 of ocidLibrariesPathURLArray
set ocidFilePathURL to ocidLibrariesPathURL's URLByAppendingPathComponent:"Preferences/com.apple.print.custompapers.plist" isDirectory:false
#####PLISTの内容を読み込んで
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listReadPlistData

if ocidPlistDict is (missing value) then
  set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
end if
##############################
#####追加するペーパーサイズ A5
set ocidAddPagerSizeDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAddPagerSizeDict's setObject:"A50margin" forKey:"id"
ocidAddPagerSizeDict's setObject:"A50margin" forKey:"name"

ocidAddPagerSizeDict's setObject:ocidTrue forKey:"custom"
ocidAddPagerSizeDict's setObject:595.275590551181 forKey:"width"
ocidAddPagerSizeDict's setObject:419.5275591 forKey:"height"

ocidAddPagerSizeDict's setObject:" " forKey:"printer"
ocidAddPagerSizeDict's setObject:0 forKey:"bottom"
ocidAddPagerSizeDict's setObject:0 forKey:"top"
ocidAddPagerSizeDict's setObject:0 forKey:"left"
ocidAddPagerSizeDict's setObject:0 forKey:"right"
#####PLISTに追加
ocidPlistDict's setObject:ocidAddPagerSizeDict forKey:"A50margin"


##############################
#####追加するペーパーサイズ A5
set ocidAddPagerSizeDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAddPagerSizeDict's setObject:"A50margin" forKey:"id"
ocidAddPagerSizeDict's setObject:"A50margin" forKey:"name"

ocidAddPagerSizeDict's setObject:ocidTrue forKey:"custom"
ocidAddPagerSizeDict's setObject:419.5275591 forKey:"width"
ocidAddPagerSizeDict's setObject:595.275590551181 forKey:"height"

ocidAddPagerSizeDict's setObject:" " forKey:"printer"
ocidAddPagerSizeDict's setObject:0 forKey:"bottom"
ocidAddPagerSizeDict's setObject:0 forKey:"top"
ocidAddPagerSizeDict's setObject:0 forKey:"left"
ocidAddPagerSizeDict's setObject:0 forKey:"right"
#####PLISTに追加
ocidPlistDict's setObject:ocidAddPagerSizeDict forKey:"A50margin"


##############################
#####追加するペーパーサイズ A4
set ocidAddPagerSizeDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAddPagerSizeDict's setObject:"A40margin" forKey:"id"
ocidAddPagerSizeDict's setObject:"A40margin" forKey:"name"

ocidAddPagerSizeDict's setObject:ocidTrue forKey:"custom"
ocidAddPagerSizeDict's setObject:841.889763779528 forKey:"width"
ocidAddPagerSizeDict's setObject:595.275590551181 forKey:"height"

ocidAddPagerSizeDict's setObject:" " forKey:"printer"
ocidAddPagerSizeDict's setObject:0 forKey:"bottom"
ocidAddPagerSizeDict's setObject:0 forKey:"top"
ocidAddPagerSizeDict's setObject:0 forKey:"left"
ocidAddPagerSizeDict's setObject:0 forKey:"right"
#####PLISTに追加
ocidPlistDict's setObject:ocidAddPagerSizeDict forKey:"A40margin"


##############################
#####追加するペーパーサイズ A4
set ocidAddPagerSizeDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAddPagerSizeDict's setObject:"A40margin" forKey:"id"
ocidAddPagerSizeDict's setObject:"A40margin" forKey:"name"

ocidAddPagerSizeDict's setObject:ocidTrue forKey:"custom"
ocidAddPagerSizeDict's setObject:595.275590551181 forKey:"width"
ocidAddPagerSizeDict's setObject:841.889763779528 forKey:"height"

ocidAddPagerSizeDict's setObject:" " forKey:"printer"
ocidAddPagerSizeDict's setObject:0 forKey:"bottom"
ocidAddPagerSizeDict's setObject:0 forKey:"top"
ocidAddPagerSizeDict's setObject:0 forKey:"left"
ocidAddPagerSizeDict's setObject:0 forKey:"right"
#####PLISTに追加
ocidPlistDict's setObject:ocidAddPagerSizeDict forKey:"A40margin"

##############################
#####追加するペーパーサイズ A3
set ocidAddPagerSizeDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAddPagerSizeDict's setObject:"A30margin" forKey:"id"
ocidAddPagerSizeDict's setObject:"A30margin" forKey:"name"

ocidAddPagerSizeDict's setObject:ocidTrue forKey:"custom"
ocidAddPagerSizeDict's setObject:1190.551181102362 forKey:"width"
ocidAddPagerSizeDict's setObject:841.889763779528 forKey:"height"

ocidAddPagerSizeDict's setObject:" " forKey:"printer"
ocidAddPagerSizeDict's setObject:0 forKey:"bottom"
ocidAddPagerSizeDict's setObject:0 forKey:"top"
ocidAddPagerSizeDict's setObject:0 forKey:"left"
ocidAddPagerSizeDict's setObject:0 forKey:"right"
#####PLISTに追加
ocidPlistDict's setObject:ocidAddPagerSizeDict forKey:"A30margin"


##############################
#####追加するペーパーサイズ A3
set ocidAddPagerSizeDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0

ocidAddPagerSizeDict's setValue:"A30margin" forKey:"id"
ocidAddPagerSizeDict's setValue:"A30margin" forKey:"name"

ocidAddPagerSizeDict's setValue:ocidTrue forKey:"custom"
ocidAddPagerSizeDict's setValue:841.889763779528 forKey:"width"
ocidAddPagerSizeDict's setValue:1190.551181102362 forKey:"height"

ocidAddPagerSizeDict's setValue:" " forKey:"printer"
ocidAddPagerSizeDict's setValue:0 forKey:"bottom"
ocidAddPagerSizeDict's setValue:0 forKey:"top"
ocidAddPagerSizeDict's setValue:0 forKey:"left"
ocidAddPagerSizeDict's setValue:0 forKey:"right"
#####PLISTに追加
ocidPlistDict's setObject:ocidAddPagerSizeDict forKey:"A30margin"


##############################
## ファイルを書き込みます
##############################
###書き込み用にバイナリーデータに変換
set ocidNSbplist to refMe's NSPropertyListBinaryFormat_v1_0
set ocidPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:ocidPlistDict format:ocidNSbplist options:0 |error|:(reference)
set ocidPlistEditData to item 1 of ocidPlistEditDataArray
set boolWritetoUrlArray to ocidPlistEditData's writeToURL:ocidFilePathURL options:0 |error|:(reference)

delay 2
#############################
###CFPreferencesを再起動
#############################
#####CFPreferencesを再起動させて変更後の値をロードさせる
set strCommandText to "/usr/bin/killall cfprefsd" as text
do shell script strCommandText

|

« [メモ]用紙サイズ(ポイント換算) | トップページ | [Jsx]上下集約ページを単一連続ページに変換 »

Admin Printer」カテゴリの記事