[Printer]余白0のppdsをダウンロード(as版)
#!/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 framework "AppKit"
use scripting additions
property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()
#############################
###AcrobatPPDの有無を確認
#############################
set ocidUserPathArray to (appFileManager's URLsForDirectory:(refMe's NSUserDirectory) inDomains:(refMe's NSLocalDomainMask))
set ocidUserPathURL to ocidUserPathArray's objectAtIndex:0
set ocidPPDFilePathURL to ocidUserPathURL's URLByAppendingPathComponent:"Shared/Library/Printers/PPDs/Contents/Resources/Acrobat/ADPDF9J.PPD" isDirectory:true
set boolFileExists to (appFileManager's fileExistsAtPath:(ocidPPDFilePathURL's |path|()) isDirectory:false)
set ocidSaveDirPathURL to ocidUserPathURL's URLByAppendingPathComponent:"Shared/Library/Printers/PPDs/Contents/Resources/Acrobat" isDirectory:true
############PPDファイルの有無チェック
if boolFileExists is true then
log "PPDはインストール済み"
set strPPDsFilePath to ocidPPDFilePathURL's |path|() as text
else
########################
###無い場合はダウンロード
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
set listResults to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#### ダウンロード
set strZipFileURL to "https://quicktimer.cocolog-nifty.com/icefloe/files/acrobat.zip"
set ocidZipFilePath to (refMe's NSString's stringWithString:(strZipFileURL))
set ocidZipFilePathURL to refMe's NSURL's alloc()'s initWithString:(ocidZipFilePath)
set ocidZipData to refMe's NSData's dataWithContentsOfURL:(ocidZipFilePathURL)
##保存
set ocidTempDirPathURL to appFileManager's temporaryDirectory()
set ocidSaveZipFilePathURL to ocidTempDirPathURL's URLByAppendingPathComponent:"acrobatppds.zip" isDirectory:false
set boolResults to ocidZipData's writeToURL:(ocidSaveZipFilePathURL) atomically:true
if boolResults is false then
return "ダウンロードに失敗しました"
end if
#### 解凍
set strZipFilePathURL to ocidSaveZipFilePathURL's |path|() as text
set strSaveDirPathURL to (ocidSaveDirPathURL's URLByDeletingLastPathComponent())'s |path|() as text
try
set theComandText to ("/usr/bin/ditto -xk \"" & strZipFilePathURL & "\" \"" & strSaveDirPathURL & "\"") as text
do shell script theComandText
end try
end if
set strDirPath to (ocidSaveDirPathURL's |path|()) as text
set aliasFilePath to (ocidSaveDirPathURL's absoluteURL()) as alias
###開く
set ocidSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
set boolSelectFileResults to ocidSharedWorkspace's selectFile:(strPPDsFilePath) inFileViewerRootedAtPath:(strDirPath)
if boolSelectFileResults = false then
tell application "Finder"
set refNewWindow to make new Finder window
set target of refNewWindow to aliasFilePath
end tell
end if
| 固定リンク
「Admin Printer」カテゴリの記事
- PPDの用紙情報をダイアログに戻して表示(2024.10.11)
- [lpoptions]デフォルトプリンタ変更(2024.10.10)
- [cupsfilter]cupsfilterを使って印刷機能でpostscriptファイルに書き出す(2024.10.10)
- PPDに記載されている用紙サイズをカスタム用紙設定する(修正)(2024.10.09)
- [makequeues] makequeuesを使ってプリンターを設定する(少し治し)サンプル AcrobatPsPrinter設定(2024.10.09)