Acrobat Distiller

[Distiller]ページサイズを指定したjoboptionを作成する


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
(*
ページサイズを指定して
joboptionをコピーします
com.cocolog-nifty.quicktimer.icefloe
*)
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"

use scripting additions

property refMe : a reference to current application

set ocidPaperDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0

#プリンタを取得
set ocidPrinterArray to refMe's NSPrinter's printerNames()
set listPrinterArray to ocidPrinterArray as list
###ダイアログを前面に出す
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###
set strTitle to ("選んでください") as text
set strPrompt to ("プリンタ名を選んでください") as text
try
  set listResponse to (choose from list listPrinterArray with title strTitle with prompt strPrompt default items (item 1 of listPrinterArray) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしましたA"
else if (item 1 of listResponse) is "キャンセル" then
return "キャンセルしましたB"
else
  set strPPDsName to ((item 1 of listResponse) & ".ppd") as text
end if

(*
set ocidPrinter to (refMe's NSPrinter's printerWithName:(strPrinterName))
この方法はmacOS14の不具合
#プリンタの名前
set strPrinterName to ocidPrinter's |name| as text
log "name:" & ocidPrinter's |name| as text
log "type:" & ocidPrinter's type as text
set ocidDescription to ocidPrinter's deviceDescription()
log "deviceDescription:" & (ocidDescription's valueForKey:("deviceDescriptionNSDeviceIsPrinter")) as text
######
*)

##########################################
##
set strPPDsDirPath to "/private/etc/cups/ppd" as text
set ocidPPDsDirPathStr to refMe's NSString's stringWithString:(strPPDsDirPath)
set ocidPPDsDirPath to ocidPPDsDirPathStr's stringByStandardizingPath()
set ocidPPDsDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidPPDsDirPath) isDirectory:false)
#ファイル収集のオプション(非表示無視)
set ocidOption to (refMe's NSDirectoryEnumerationSkipsHiddenFiles)
#収集するキー(パスと名前)
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidKeysArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidKeysArray's addObject:(refMe's NSURLPathKey)
ocidKeysArray's addObject:(refMe's NSURLNameKey)
set lisrResponse to (appFileManager's contentsOfDirectoryAtURL:(ocidPPDsDirPathURL) includingPropertiesForKeys:(ocidKeysArray) options:(ocidOption) |error|:(reference))
if (item 2 of lisrResponse) = (missing value) then
  set ocidPPDsFilePathURLArray to (item 1 of lisrResponse)
else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
end if
##ファイル名とパスのレコードを作成
set ocidName2URLDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
repeat with itemFilePathURL in ocidPPDsFilePathURLArray
  set ocidFileName to itemFilePathURL's lastPathComponent()
(ocidName2URLDict's setObject:(itemFilePathURL) forKey:(ocidFileName))
end repeat
set ocidPPDsFilePathURL to ocidName2URLDict's objectForKey:(strPPDsName)

##########################################
##PPD読み込み
set listResponse to refMe's NSString's alloc()'s initWithContentsOfURL:(ocidPPDsFilePathURL) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
if (item 2 of lisrResponse) = (missing value) then
  set ocidReadString to (item 1 of listResponse)
else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
end if

##########################################
##PPD解析
set ocidCharSet to refMe's NSCharacterSet's newlineCharacterSet()
set ocidPPDsLineArray to ocidReadString's componentsSeparatedByCharactersInSet:(ocidCharSet)
##格納用のレコード
set ocidPaperDimensionDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
##全行対象
repeat with itemArray in ocidPPDsLineArray
  set boolImageableArea to (itemArray's containsString:("*PaperDimension")) as boolean
  if boolImageableArea is true then
    set ocidLineString to (itemArray's stringByReplacingOccurrencesOfString:("*PaperDimension ") withString:(""))
    set ocidCharSet to (refMe's NSMutableCharacterSet's characterSetWithCharactersInString:(":"))
    set ocidLineArray to (ocidLineString's componentsSeparatedByCharactersInSet:(ocidCharSet))
    set ocidPaperName to (ocidLineArray's objectAtIndex:(0))
    set ocidDimensionStr to (ocidLineArray's objectAtIndex:(1))
    set ocidDimension to (ocidDimensionStr's stringByReplacingOccurrencesOfString:(" \"") withString:(""))
    set ocidDimensionStr to (ocidDimension's stringByReplacingOccurrencesOfString:("\"") withString:(""))
    set ocidCharSet to (refMe's NSMutableCharacterSet's characterSetWithCharactersInString:(" "))
    set ocidDimensionArray to (ocidDimensionStr's componentsSeparatedByCharactersInSet:(ocidCharSet))
    set ocidPaperW to (ocidDimensionArray's objectAtIndex:(0))'s floatValue
    set ocidPaperH to (ocidDimensionArray's objectAtIndex:(1))'s floatValue
    ##サイズにして格納しておく(ここでは不要なんだけど後で何か使うかなと)
    set ocidPageSize to refMe's NSSize's NSMakeSize(ocidPaperW, ocidPaperH)
(ocidPaperDimensionDict's setObject:(ocidPageSize) forKey:(ocidPaperName))
  end if
end repeat

################
##用紙名だけのリスト
set ocidAllKeys to ocidPaperDimensionDict's allKeys()
##ソート
set ocidPaperNameArray to ocidAllKeys's sortedArrayUsingSelector:("localizedStandardCompare:")
set listAllKeys to ocidPaperNameArray as list

##########################################
##ダイアログ
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###
set strTitle to ("選んでください") as text
set strPrompt to ("用紙名を選んでください\n用紙サイズを戻します") as text
try
  set listResponse to (choose from list listAllKeys with title strTitle with prompt strPrompt default items (item 1 of listAllKeys) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしましたA"
else if (item 1 of listResponse) is "キャンセル" then
return "キャンセルしましたB"
else
  set strPaperName to (item 1 of listResponse) as text
end if
##数値で取得
set ocidSizeList to ocidPaperDimensionDict's objectForKey:(strPaperName)
set ocidDecW to (ocidSizeList's width)'s floatValue
set ocidDecH to (ocidSizeList's height)'s floatValue
##小数点以下2桁
set ocidFormatter to refMe's NSNumberFormatter's alloc()'s init()
ocidFormatter's setRoundingMode:(refMe's NSNumberFormatterRoundFloor)
ocidFormatter's setNumberStyle:(refMe's NSNumberFormatterNoStyle)
ocidFormatter's setMaximumFractionDigits:(2)
set ocidFloat4W to ocidFormatter's stringFromNumber:(ocidDecW)
set ocidFloat4H to ocidFormatter's stringFromNumber:(ocidDecH)
##テキストにしておく
set strW to ocidFloat4W as text
set strH to ocidFloat4H as text

##########################################
##Joboptionの収集
##ファイルパスの格納用のリスト
set ocidFilePathURLArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
#ファイル収集のオプション(非表示無視)
set ocidOption to (refMe's NSDirectoryEnumerationSkipsHiddenFiles)
#収集するキー(パスと名前)
set ocidKeysArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidKeysArray's addObject:(refMe's NSURLPathKey)
ocidKeysArray's addObject:(refMe's NSURLNameKey)
######
#収集するパス
set listDirPath to {"Adobe/Adobe PDF/Settings", "Adobe/Adobe PDF/Extras"}
#ローカルドメインの収集
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSLocalDomainMask))
set ocidLocalAppSupDirPathURL to ocidURLsArray's firstObject()
#収集して
repeat with itemDirPath in listDirPath
  set ocidChkDirPathURL to (ocidLocalAppSupDirPathURL's URLByAppendingPathComponent:(itemDirPath) isDirectory:(true))
  set lisrResponse to (appFileManager's contentsOfDirectoryAtURL:(ocidChkDirPathURL) includingPropertiesForKeys:(ocidKeysArray) options:(ocidOption) |error|:(reference))
  if (item 2 of lisrResponse) = (missing value) then
    set ocidGetFilePathURLArray to (item 1 of lisrResponse)
  else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
  end if
  ##リストに追加
(ocidFilePathURLArray's addObjectsFromArray:(ocidGetFilePathURLArray))
end repeat
######
#ユーザードメインの収集
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLocalAppSupDirPathURL to ocidURLsArray's firstObject()
#収集して
repeat with itemDirPath in listDirPath
  set ocidChkDirPathURL to (ocidLocalAppSupDirPathURL's URLByAppendingPathComponent:(itemDirPath) isDirectory:(true))
  set lisrResponse to (appFileManager's contentsOfDirectoryAtURL:(ocidChkDirPathURL) includingPropertiesForKeys:(ocidKeysArray) options:(ocidOption) |error|:(reference))
  if (item 2 of lisrResponse) = (missing value) then
    set ocidGetFilePathURLArray to (item 1 of lisrResponse)
  else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
  end if
  ##リストに追加
(ocidFilePathURLArray's addObjectsFromArray:(ocidGetFilePathURLArray))
end repeat
######
##ファイル名とパスのレコードを作成
set ocidName2URLDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
repeat with itemFilePathURL in ocidFilePathURLArray
  set ocidFileName to itemFilePathURL's lastPathComponent()
(ocidName2URLDict's setObject:(itemFilePathURL) forKey:(ocidFileName))
end repeat
######
##ファイル名だけのリスト
set ocidAllKeys to ocidName2URLDict's allKeys()
##ソート
set ocidFileNameArray to ocidAllKeys's sortedArrayUsingSelector:("localizedStandardCompare:")
set listFileNameArray to ocidFileNameArray as list

##########################################
##ダイアログ
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###
set strTitle to ("選んでください") as text
set strPrompt to ("JOBOPTIONを選んでください\n用紙サイズを設定します") as text
try
  set listResponse to (choose from list listFileNameArray with title strTitle with prompt strPrompt default items (item 1 of listFileNameArray) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしましたA"
else if (item 1 of listResponse) is "キャンセル" then
return "キャンセルしましたB"
else
  set strJobOptionName to (item 1 of listResponse) as text
end if
##########################################
##joboptionsのURL
set ocidOptionFilePathURL to ocidName2URLDict's objectForKey:(strJobOptionName)
##joboptions読み込み
set listResponse to refMe's NSString's alloc()'s initWithContentsOfURL:(ocidOptionFilePathURL) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
if (item 2 of lisrResponse) = (missing value) then
  set ocidReadJoboption to (item 1 of listResponse)
else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
end if
#セットする値
set strSetValue to ("/PageSize [" & strW & " " & strH & "]") as text

##########################################
##改行UNIXを強制
set ocidTmpJoboption to (ocidReadJoboption's stringByReplacingOccurrencesOfString:("\n\r") withString:("\n"))
set ocidTmpJoboption to (ocidTmpJoboption's stringByReplacingOccurrencesOfString:("\r") withString:("\n"))
set ocidReadJoboption to (ocidTmpJoboption's stringByReplacingOccurrencesOfString:("\n\n") withString:("\n"))
##改行でリストに
set ocidCharSet to refMe's NSCharacterSet's newlineCharacterSet()
set ocidJobOptionLineArray to ocidReadJoboption's componentsSeparatedByCharactersInSet:(ocidCharSet)
set ocidSaveOptionArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
##全行調べて ページサイズを置換
repeat with itemJobOptionLineArray in ocidJobOptionLineArray
  set boolContain to (itemJobOptionLineArray's containsString:("/PageSize "))
  if boolContain is true then
(ocidSaveOptionArray's addObject:(strSetValue))
  else
(ocidSaveOptionArray's addObject:(itemJobOptionLineArray))
  end if
end repeat
##リストをテキストに戻して
set ocidSaveString to ocidSaveOptionArray's componentsJoinedByString:("\n")

##########################################
##ファイル名
set strSaveFileName to (strPaperName & "_" & strPPDsName & "_" & strJobOptionName) as text
set ocidSaveFileName to refMe's NSString's stringWithString:(strSaveFileName)
set ocidSaveFileName to (ocidSaveFileName's stringByReplacingOccurrencesOfString:("/") withString:("_"))
##保存先
set ocidSaveDirPathURL to (ocidLocalAppSupDirPathURL's URLByAppendingPathComponent:("Adobe/Adobe PDF/Settings") isDirectory:(true))
set ocidSaveFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidSaveFileName) isDirectory:(false))
##保存
set listDone to ocidSaveString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
if (item 1 of listDone) is true then
return "正常終了"
else if (item 1 of listDone) is false then
log (item 2 of listDone)'s localizedDescription() as text
return "保存に失敗しました"
end if



return








|

[Distiller]postscriptファイルをPDFに変換する


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# テキスト系式のapplescriptだとコンパイル時に起動するのでダメ
# コンパイル済みのscpt系式で保存してください
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"

use scripting additions
property refMe : a reference to current application

##ファイルパスの格納用のリスト
set ocidFilePathURLArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
#ファイル収集のオプション(非表示無視)
set ocidOption to (refMe's NSDirectoryEnumerationSkipsHiddenFiles)
#収集するキー(パスと名前)
set ocidKeysArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidKeysArray's addObject:(refMe's NSURLPathKey)
ocidKeysArray's addObject:(refMe's NSURLNameKey)
######
#収集するパス
set listDirPath to {"Adobe/Adobe PDF/Settings", "Adobe/Adobe PDF/Extras"}
#ローカルドメインの収集
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSLocalDomainMask))
set ocidLocalAppSupDirPathURL to ocidURLsArray's firstObject()
#収集して
repeat with itemDirPath in listDirPath
  set ocidChkDirPathURL to (ocidLocalAppSupDirPathURL's URLByAppendingPathComponent:(itemDirPath) isDirectory:(true))
  set lisrResponse to (appFileManager's contentsOfDirectoryAtURL:(ocidChkDirPathURL) includingPropertiesForKeys:(ocidKeysArray) options:(ocidOption) |error|:(reference))
  if (item 2 of lisrResponse) = (missing value) then
    set ocidGetFilePathURLArray to (item 1 of lisrResponse)
  else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
  end if
  ##リストに追加
(ocidFilePathURLArray's addObjectsFromArray:(ocidGetFilePathURLArray))
end repeat
######
#ユーザードメインの収集
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLocalAppSupDirPathURL to ocidURLsArray's firstObject()
#収集して
repeat with itemDirPath in listDirPath
  set ocidChkDirPathURL to (ocidLocalAppSupDirPathURL's URLByAppendingPathComponent:(itemDirPath) isDirectory:(true))
  set lisrResponse to (appFileManager's contentsOfDirectoryAtURL:(ocidChkDirPathURL) includingPropertiesForKeys:(ocidKeysArray) options:(ocidOption) |error|:(reference))
  if (item 2 of lisrResponse) = (missing value) then
    set ocidGetFilePathURLArray to (item 1 of lisrResponse)
  else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
  end if
  ##リストに追加
(ocidFilePathURLArray's addObjectsFromArray:(ocidGetFilePathURLArray))
end repeat
######
##ファイル名とパスのレコードを作成
set ocidName2URLDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
repeat with itemFilePathURL in ocidFilePathURLArray
  set ocidFileName to itemFilePathURL's lastPathComponent()
(ocidName2URLDict's setObject:(itemFilePathURL) forKey:(ocidFileName))
end repeat
######
##ファイル名だけのリスト
set ocidAllKeys to ocidName2URLDict's allKeys()
##ソート
set ocidFileNameArray to ocidAllKeys's sortedArrayUsingSelector:("localizedStandardCompare:")
set listFileNameArray to ocidFileNameArray as list
#最小ファイルサイズが何番目か?
set numIndex to ocidFileNameArray's indexOfObject:("Smallest File Size.joboptions")
set numIndex to (numIndex + 1) as integer
##################
#ダイアログ
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###
set strTitle to ("選んでください") as text
set strPrompt to ("ジョブオプションを選んでください") as text
try
  set listResponse to (choose from list listFileNameArray with title strTitle with prompt strPrompt default items (item numIndex of listFileNameArray) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしましたA"
else if (item 1 of listResponse) is "キャンセル" then
return "キャンセルしましたB"
else
  set strResponse to (item 1 of listResponse) as text
end if
##
set ocidChooseFilePathURL to ocidName2URLDict's objectForKey:(strResponse)
set strChooseFilePath to ocidChooseFilePathURL's |path| as text
set strAdobePDFSettingsPath to strChooseFilePath as text

###ダイアログ
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias

set listUTI to {"com.adobe.postscript"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
on error
log "エラーしました"
return "エラーしました"
end try

set strPsFilePath to (POSIX path of aliasFilePath) as text
set ocidFilePathStr to refMe's NSString's stringWithString:(strPsFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
set strDestinationPath to ocidContainerDirPathURL's |path| as text


tell application "Acrobat Distiller" to launch
##起動待ち最大10秒
repeat 20 times
  tell application id "com.adobe.distiller"
    set boolFrontmost to frontmost as boolean
  end tell
  if boolFrontmost is false then
    tell application id "com.adobe.distiller"
activate
    end tell
delay 0.5
  else if boolFrontmost is true then
    exit repeat
  end if
end repeat

tell application "Acrobat Distiller"
Distill sourcePath strPsFilePath destinationPath strDestinationPath adobePDFSettingsPath strAdobePDFSettingsPath
end tell

tell application "Acrobat Distiller"
quit
end tell

|

[Distiller]EPSをPDFに変換する


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# テキスト系式のapplescriptだとコンパイル時に起動するのでダメ
# コンパイル済みのscpt系式で保存してください
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"

use scripting additions
property refMe : a reference to current application


tell application id "com.adobe.distiller" to quit

##ファイルパスの格納用のリスト
set ocidFilePathURLArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
#ファイル収集のオプション(非表示無視)
set ocidOption to (refMe's NSDirectoryEnumerationSkipsHiddenFiles)
#収集するキー(パスと名前)
set ocidKeysArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidKeysArray's addObject:(refMe's NSURLPathKey)
ocidKeysArray's addObject:(refMe's NSURLNameKey)
######
#収集するパス
set listDirPath to {"Adobe/Adobe PDF/Settings", "Adobe/Adobe PDF/Extras"}
#ローカルドメインの収集
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSLocalDomainMask))
set ocidLocalAppSupDirPathURL to ocidURLsArray's firstObject()
#収集して
repeat with itemDirPath in listDirPath
  set ocidChkDirPathURL to (ocidLocalAppSupDirPathURL's URLByAppendingPathComponent:(itemDirPath) isDirectory:(true))
  set lisrResponse to (appFileManager's contentsOfDirectoryAtURL:(ocidChkDirPathURL) includingPropertiesForKeys:(ocidKeysArray) options:(ocidOption) |error|:(reference))
  if (item 2 of lisrResponse) = (missing value) then
    set ocidGetFilePathURLArray to (item 1 of lisrResponse)
  else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
  end if
  ##リストに追加
(ocidFilePathURLArray's addObjectsFromArray:(ocidGetFilePathURLArray))
end repeat
######
#ユーザードメインの収集
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLocalAppSupDirPathURL to ocidURLsArray's firstObject()
#収集して
repeat with itemDirPath in listDirPath
  set ocidChkDirPathURL to (ocidLocalAppSupDirPathURL's URLByAppendingPathComponent:(itemDirPath) isDirectory:(true))
  set lisrResponse to (appFileManager's contentsOfDirectoryAtURL:(ocidChkDirPathURL) includingPropertiesForKeys:(ocidKeysArray) options:(ocidOption) |error|:(reference))
  if (item 2 of lisrResponse) = (missing value) then
    set ocidGetFilePathURLArray to (item 1 of lisrResponse)
  else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
  end if
  ##リストに追加
(ocidFilePathURLArray's addObjectsFromArray:(ocidGetFilePathURLArray))
end repeat
######
##ファイル名とパスのレコードを作成
set ocidName2URLDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
repeat with itemFilePathURL in ocidFilePathURLArray
  set ocidFileName to itemFilePathURL's lastPathComponent()
(ocidName2URLDict's setObject:(itemFilePathURL) forKey:(ocidFileName))
end repeat
######
##ファイル名だけのリスト
set ocidAllKeys to ocidName2URLDict's allKeys()
##ソート
set ocidFileNameArray to ocidAllKeys's sortedArrayUsingSelector:("localizedStandardCompare:")
set listFileNameArray to ocidFileNameArray as list
#最小ファイルサイズが何番目か?
set numIndex to ocidFileNameArray's indexOfObject:("Smallest File Size.joboptions")
set numIndex to (numIndex + 1) as integer
##################
#ダイアログ
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###
set strTitle to ("選んでください") as text
set strPrompt to ("ジョブオプションを選んでください") as text
try
  set listResponse to (choose from list listFileNameArray with title strTitle with prompt strPrompt default items (item numIndex of listFileNameArray) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしましたA"
else if (item 1 of listResponse) is "キャンセル" then
return "キャンセルしましたB"
else
  set strResponse to (item 1 of listResponse) as text
end if
##
set ocidChooseFilePathURL to ocidName2URLDict's objectForKey:(strResponse)
set strChooseFilePath to ocidChooseFilePathURL's |path| as text
set strAdobePDFSettingsPath to strChooseFilePath as text

###ダイアログ
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias

set listUTI to {"com.adobe.encapsulated-postscript"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
on error
log "エラーしました"
return "エラーしました"
end try

set strPsFilePath to (POSIX path of aliasFilePath) as text
set ocidFilePathStr to refMe's NSString's stringWithString:(strPsFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
set strDestinationPath to ocidContainerDirPathURL's |path| as text


tell application "Acrobat Distiller" to launch
##起動待ち最大10秒
repeat 20 times
  tell application id "com.adobe.distiller"
    set boolFrontmost to frontmost as boolean
  end tell
  if boolFrontmost is false then
    tell application id "com.adobe.distiller"
activate
    end tell
delay 0.5
  else if boolFrontmost is true then
    exit repeat
  end if
end repeat

tell application "Acrobat Distiller"
Distill sourcePath strPsFilePath destinationPath strDestinationPath adobePDFSettingsPath strAdobePDFSettingsPath
end tell

return
tell application "Acrobat Distiller"
quit
end tell

|

[Distiller]キャッシュをゴミ箱に入れる


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#【重要】 Adobeのアプリケーションを【重要】
#一旦全て終了させてから実行してください
# 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()

###################################
########まずは処理するアプリケーションを終了させる
###################################
try
  tell application id "com.adobe.distiller" to quit
end try
set ocidRunningApplication to refMe's NSRunningApplication
set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:("com.adobe.distiller"))
###複数起動時も順番に終了
repeat with itemAppArray in ocidAppArray
  ###終了
itemAppArray's terminate()
end repeat
##1秒まって終了を確認
delay 1
##終了できない場合は強制終了
repeat with itemAppArray in ocidAppArray
  set boolTerminate to itemAppArray's terminated
  if boolTerminate = false then
itemAppArray's forceTerminate()
  end if
end repeat
##使いたくないがしかたがない
try
do shell script "/usr/bin/killall Distiller"
end try
###################################
########
###################################
log doMoveToTrash("~/Library/Application Scripts/com.adobe.distiller")
log doMoveToTrash("~/Library/Caches/Acrobat")
log doMoveToTrash("~/Library/Caches/Adobe")
log doMoveToTrash("~/Library/Caches/com.adobe.Acrobat.Pro")
log doMoveToTrash("~/Library/Caches/com.adobe.distiller")
log doMoveToTrash("~/Library/Caches/com.adobe.Reader")
log doMoveToTrash("~/Library/WebKit/com.adobe.crashreporter")
log doMoveToTrash("~/Library/WebKit/com.adobe.distiller")
log doMoveToTrash("~/Library/Logs/Adobe")
log doMoveToTrash("~/Library/HTTPStorages/com.adobe.distiller")
log doMoveToTrash("~/Library/HTTPStorages/com.adobe.Acrobat.Pro")
log doMoveToTrash("~/Library/HTTPStorages/com.adobe.Reader")
##
log doMoveToTrash("~/Library/Application Support/Adobe/AcroCef/DC/Acrobat/Cache")
log doMoveToTrash("~/Library/Application Support/Adobe/AcroCef/2020/Acrobat/Cache")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/Distiller DC/FontCache")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/SaveAsAdobePDF DC/FontCache")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/Preflight Acrobat Continuous/FontCache")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/Distiller DC/Messages.log")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/DC/BHCache")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/DC/AdobeCMapFnt22.lst")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/DC/AdobeCMapFnt24.lst")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/DC/AdobeSysFnt22.lst")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/DC/AdobeSysFnt24.lst")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/DC/JSCache")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/DC/ThumbCache")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/DC/ToolsSearchCacheAcro")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/DC/UserCache64.bin")
log doMoveToTrash("~/Library/Application Support/Adobe/Acrobat/DC/ProtectedView¥AdobeSysFnt22.lst")


###################################
########キャッシュNSTemporaryDirectory
###################################
### T
set ocidTempDir to (refMe's NSTemporaryDirectory())
set ocidTemporaryTPathURL to refMe's NSURL's fileURLWithPath:(ocidTempDir)
set ocidPropertiesArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidPropertiesArray's addObject:(refMe's NSURLIsRegularFileKey)
ocidPropertiesArray's addObject:(refMe's NSURLPathKey)
ocidPropertiesArray's addObject:(refMe's NSURLNameKey)
set listResponse to appFileManager's contentsOfDirectoryAtURL:(ocidTemporaryTPathURL) includingPropertiesForKeys:(ocidPropertiesArray) options:(refMe's NSDirectoryEnumerationSkipsSubdirectoryDescendants) |error|:(reference)
log item 2 of listResponse

repeat with itemURL in (item 1 of listResponse)
  set listResourceValue to (itemURL's getResourceValue:(reference) forKey:(refMe's NSURLNameKey) |error|:(missing value))
  set ocidFileName to (item 2 of listResourceValue)
  if (ocidFileName's hasPrefix:("Acr")) = true then
log itemURL's lastPathComponent() as text
    
  end if
end repeat

log doMoveToTrash(ocidTemporaryTPathURL's URLByAppendingPathComponent:"AdobeIDataSync")
###
set ocidTempURL to ocidTemporaryTPathURL's URLByDeletingLastPathComponent()
### C
set ocidTemporaryCPathURL to ocidTempURL's URLByAppendingPathComponent:"C"

log doMoveToTrash(ocidTemporaryCPathURL's URLByAppendingPathComponent:"com.adobe.Acrobat.Pro")
log doMoveToTrash(ocidTemporaryCPathURL's URLByAppendingPathComponent:"com.adobe.Reader")
log doMoveToTrash(ocidTemporaryCPathURL's URLByAppendingPathComponent:"com.adobe.distiller")

###################################
########処理 ゴミ箱に入れる
###################################

to doMoveToTrash(argFilePath)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  #########################################
  ###渡された値のClassを調べてとりあえずNSURLにする
  set refClass to class of argFilePath
  if refClass is list then
return "エラー:リストは処理しません"
  else if refClass is text then
log "テキストパスです"
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:argFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else if refClass is alias then
log "エイリアスパスです"
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:strArgFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else
    set refClass to (className() of argFilePath) as text
    if refClass contains "NSPathStore2" then
log "NSPathStore2です"
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:argFilePath)
    else if refClass contains "NSCFString" then
log "NSCFStringです"
      set ocidArgFilePath to argFilePath's stringByStandardizingPath
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
    else if refClass contains "NSURL" then
      set ocidArgFilePathURL to argFilePath
log "NSURLです"
    end if
  end if
  #########################################
  ###
  -->false
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue
  -->true
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue
  #########################################
  ###NSURLがエイリアス実在するか?
  set ocidArgFilePath to ocidArgFilePathURL's |path|()
  set boolFileAlias to appFileManager's fileExistsAtPath:(ocidArgFilePath)
  ###パス先が実在しないなら処理はここまで
  if boolFileAlias = false then
log ocidArgFilePath as text
log "処理中止 パス先が実在しない"
return false
  end if
  #########################################
  ###NSURLがディレクトリなのか?ファイルなのか?
  set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference)
  # log (item 1 of listBoolDir)
  # log (item 2 of listBoolDir)
  # log (item 3 of listBoolDir)
  if (item 2 of listBoolDir) = ocidTrue then
    #########################################
log "ディレクトリです"
log ocidArgFilePathURL's |path| as text
    ##内包リスト
    set listResult to appFileManager's contentsOfDirectoryAtURL:ocidArgFilePathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
    ###結果
    set ocidContentsPathURLArray to item 1 of listResult
    ###リストの数だけ繰り返し
    repeat with itemContentsPathURL in ocidContentsPathURLArray
      ###ゴミ箱に入れる
      set listResult to (appFileManager's trashItemAtURL:itemContentsPathURL resultingItemURL:(missing value) |error|:(reference))
    end repeat
  else
    #########################################
log "ファイルです"
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsAliasFileKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "エイリアスは処理しません"
return false
    end if
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSymbolicLinkKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "シンボリックリンクは処理しません"
return false
    end if
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSystemImmutableKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "システムファイルは処理しません"
return false
    end if
    ###ファイルをゴミ箱に入れる
    set listResult to (appFileManager's trashItemAtURL:ocidArgFilePathURL resultingItemURL:(missing value) |error|:(reference))
  end if
return true
end doMoveToTrash


|

[Distiller]強制終了


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

#!/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 framework "UniformTypeIdentifiers"

use scripting additions
property refMe : a reference to current application

try
  tell application id "com.adobe.distiller" to quit
end try
set ocidRunningApplication to refMe's NSRunningApplication
set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:("com.adobe.distiller"))
###複数起動時も順番に終了
repeat with itemAppArray in ocidAppArray
  ###終了
itemAppArray's terminate()
end repeat
##1秒まって終了を確認
delay 1
##終了できない場合は強制終了
repeat with itemAppArray in ocidAppArray
  set boolTerminate to itemAppArray's terminated
  if boolTerminate = false then
itemAppArray's forceTerminate()
  end if
end repeat
##使いたくないがしかたがない
try
do shell script "/usr/bin/killall Distiller"
end try
return

|

[Distiller]起動をまつ


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# テキスト系式のapplescriptだとコンパイル時に起動するのでダメ
# コンパイル済みのscpt系式で保存してください
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.5"
use framework "Foundation"
use framework "AppKit"
use scripting additions

tell application id "com.adobe.distiller" to launch

##起動待ち最大10秒
repeat 20 times
  tell application id "com.adobe.distiller"
    set boolFrontmost to frontmost as boolean
  end tell
  if boolFrontmost is false then
    tell application id "com.adobe.distiller"
activate
    end tell
delay 0.5
  else if boolFrontmost is true then
    exit repeat
  end if
end repeat



|

[Distiller]Psファイルをオプション選んでPDFに変換


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use framework "Foundation"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application

##ファイルパスの格納用のリスト
set ocidFilePathURLArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
#ファイル収集のオプション(非表示無視)
set ocidOption to (refMe's NSDirectoryEnumerationSkipsHiddenFiles)
#収集するキー(パスと名前)
set ocidKeysArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidKeysArray's addObject:(refMe's NSURLPathKey)
ocidKeysArray's addObject:(refMe's NSURLNameKey)
######
#収集するパス
set listDirPath to {"Adobe/Adobe PDF/Settings", "Adobe/Adobe PDF/Extras"}
#ローカルドメインの収集
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSLocalDomainMask))
set ocidLocalAppSupDirPathURL to ocidURLsArray's firstObject()
#収集して
repeat with itemDirPath in listDirPath
  set ocidChkDirPathURL to (ocidLocalAppSupDirPathURL's URLByAppendingPathComponent:(itemDirPath) isDirectory:(true))
  set lisrResponse to (appFileManager's contentsOfDirectoryAtURL:(ocidChkDirPathURL) includingPropertiesForKeys:(ocidKeysArray) options:(ocidOption) |error|:(reference))
  if (item 2 of lisrResponse) = (missing value) then
    set ocidGetFilePathURLArray to (item 1 of lisrResponse)
  else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
  end if
  ##リストに追加
(ocidFilePathURLArray's addObjectsFromArray:(ocidGetFilePathURLArray))
end repeat
######
#ユーザードメインの収集
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLocalAppSupDirPathURL to ocidURLsArray's firstObject()
#収集して
repeat with itemDirPath in listDirPath
  set ocidChkDirPathURL to (ocidLocalAppSupDirPathURL's URLByAppendingPathComponent:(itemDirPath) isDirectory:(true))
  set lisrResponse to (appFileManager's contentsOfDirectoryAtURL:(ocidChkDirPathURL) includingPropertiesForKeys:(ocidKeysArray) options:(ocidOption) |error|:(reference))
  if (item 2 of lisrResponse) = (missing value) then
    set ocidGetFilePathURLArray to (item 1 of lisrResponse)
  else if (item 2 of lisrResponse) ≠ (missing value) then
log (item 2 of lisrResponse)'s localizedDescription() as text
  end if
  ##リストに追加
(ocidFilePathURLArray's addObjectsFromArray:(ocidGetFilePathURLArray))
end repeat
######
##ファイル名とパスのレコードを作成
set ocidName2URLDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
repeat with itemFilePathURL in ocidFilePathURLArray
  set ocidFileName to itemFilePathURL's lastPathComponent()
(ocidName2URLDict's setObject:(itemFilePathURL) forKey:(ocidFileName))
end repeat
######
##ファイル名だけのリスト
set ocidAllKeys to ocidName2URLDict's allKeys()
##ソート
set ocidFileNameArray to ocidAllKeys's sortedArrayUsingSelector:("localizedStandardCompare:")
set listFileNameArray to ocidFileNameArray as list
#最小ファイルサイズが何番目か?
set numIndex to ocidFileNameArray's indexOfObject:("Smallest File Size.joboptions")
set numIndex to (numIndex + 1) as integer
##################
#ダイアログ
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###
set strTitle to ("選んでください") as text
set strPrompt to ("ジョブオプションを選んでください") as text
try
  set listResponse to (choose from list listFileNameArray with title strTitle with prompt strPrompt default items (item numIndex of listFileNameArray) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしましたA"
else if (item 1 of listResponse) is "キャンセル" then
return "キャンセルしましたB"
else
  set strResponse to (item 1 of listResponse) as text
end if
##
set ocidChooseFilePathURL to ocidName2URLDict's objectForKey:(strResponse)
set strChooseFilePath to ocidChooseFilePathURL's |path| as text
set strAdobePDFSettingsPath to strChooseFilePath as text

###ダイアログ
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias

set listUTI to {"com.adobe.postscript"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
on error
log "エラーしました"
return "エラーしました"
end try

set strPsFilePath to (POSIX path of aliasFilePath) as text
set ocidFilePathStr to refMe's NSString's stringWithString:(strPsFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
set strDestinationPath to ocidContainerDirPathURL's |path| as text


tell application "Acrobat Distiller" to launch
##起動待ち最大10秒
repeat 20 times
  tell application id "com.adobe.distiller"
    set boolFrontmost to frontmost as boolean
  end tell
  if boolFrontmost is false then
    tell application id "com.adobe.distiller"
activate
    end tell
delay 0.5
  else if boolFrontmost is true then
    exit repeat
  end if
end repeat

tell application "Acrobat Distiller"
Distill sourcePath strPsFilePath destinationPath strDestinationPath adobePDFSettingsPath strAdobePDFSettingsPath
end tell

tell application "Acrobat Distiller"
quit
end tell

|

[macOS13.3]NUP(nIN1)集約PDF作成時の余白0

印刷画面から余白0の集約PDFを作成する場合

『たぶん』OS側の不具合だと思いますが
(PDF生成時は用紙設定時の余白を考慮しないって言われたらアレだけど…)
PDFをページ集約印刷する際の余白0
現時点では、一旦PostScriptで出力してPDF化しないと『余白』入ります。

前提条件:余白0に設定されている用紙設定が必要です。

PostScriptをPDF化するには
1:Acrobat Distillerを使う
2:Skim等のサードパーティ製アプリケーションを使う
3:cupsfilterを使う 
4:オンラインサービスを利用する※
などの方法があります。
※業務利用の場合オンラインサービスに業務内容の一部をアップロードする事自体
セキュリティ違反となる場合がありあす。利用に際しては、職場のセキュリティ担当者の許可が必要です。



余白0の用紙設定を使う
1:余白設定0のPPDを使ったプリンタを作成する
2:自分で余白0の用紙設定を作る

どちらか


PostScriptをPDF化
1:Acrobat Distillerを使う
アカウントは有料ですがインストールダケはできます
https://helpx.adobe.com/jp/acrobat/kb/acrobat-dc-downloads.html
2:Skim等のサードパーティ製アプリケーションを使う
https://quicktimer.cocolog-nifty.com/icefloe/2023/04/post-b7beb6.html
3:cupsfilterを使う 
https://quicktimer.cocolog-nifty.com/icefloe/2023/02/post-26866c.html


余白0の用紙設定を使う
1:余白設定0のPPD
[PPDs]AcrobatPPDsをダウンロードして利用可能にする
https://quicktimer.cocolog-nifty.com/icefloe/2023/04/post-089275.html
2:自分で余白0の用紙設定を作る
https://quicktimer.cocolog-nifty.com/icefloe/2023/04/post-8097d1.html


PostScriptファイルを生成する
プリンタ画面からPostScriptファイルを生成する
Screencapture1720x639

|

[Distiller]PSファイルをPDFに変換する その2

#!/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



###Acrobat Distillerフォルダを作る
tell application "Finder"
set aliasShared to path to shared documents from user domain
set boolFolderExists to (exists of (folder "Acrobat Distiller" of folder aliasShared)) as boolean
if boolFolderExists is false then
make new folder at aliasShared with properties {name:"Acrobat Distiller", owner privileges:"read write", group privileges:"read write", everyones privileges:"read write", comment:"このフォルダはAcrobat Distiller用のフォルダです", description:"スクリプトが生成したフォルダです", label index:3}
end if
set aliasDistillerDir to folder "Acrobat Distiller" of folder aliasShared as alias
set strDistillerDir to POSIX path of aliasDistillerDir as text
end tell
###inフォルダを作る
tell application "Finder"
set boolFolderExists to (exists of (folder "in" of folder aliasDistillerDir)) as boolean
if boolFolderExists is false then
make new folder at aliasDistillerDir with properties {name:"in", owner privileges:"read write", group privileges:"read write", everyones privileges:"read write", comment:"このフォルダはAcrobat Distiller用のフォルダです", description:"スクリプトが生成したフォルダです", label index:3}
end if
set aliasDistillerInDir to folder "in" of folder aliasDistillerDir as alias
set strDistillerInDir to POSIX path of aliasDistillerInDir as text
end tell
###outフォルダを作る
tell application "Finder"
set boolFolderExists to (exists of (folder "out" of folder aliasDistillerDir)) as boolean
if boolFolderExists is false then
make new folder at aliasDistillerDir with properties {name:"out", owner privileges:"read write", group privileges:"read write", everyones privileges:"read write", comment:"このフォルダはAcrobat Distiller用のフォルダです", description:"スクリプトが生成したフォルダです", label index:3}
end if
set aliasDistilleroutDir to folder "out" of folder aliasDistillerDir as alias
set strDistilleroutDir to POSIX path of aliasDistilleroutDir as text
end tell
###ファイルを選択
set aliasFile to (choose file with prompt "PSファイルを選んでください" default location aliasDistillerDir of type {"com.adobe.postscript"} without invisibles, showing package contents and multiple selections allowed) as alias

###Print.joboptionsの一覧を取得
set strCommandText to ("ls -d /Library/Application\\ Support/Adobe/Adobe\\ PDF/Settings/*")
set strJobOption to do shell script strCommandText
set AppleScript's text item delimiters to "\r"
set listJobOption to every text item of strJobOption


set strCommandText to ("ls -d $HOME/Library/Application\\ Support/Adobe/Adobe\\ PDF/Settings/*")
set strUserJobOption to do shell script strCommandText
set AppleScript's text item delimiters to "\r"
set listUserJobOption to every text item of strUserJobOption

set listJobOption to listJobOption & listUserJobOption



###Print.joboptionsを選択
try
set objResponse to (choose from list listJobOption with title "Print.joboptions" with prompt "ジョブオプションを選んでください" default items (item 1 of listJobOption) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed)
on error
log "エラーしました"
return
end try
if objResponse is false then
return
end if
set theResponse to (objResponse) as text

###ディスティラでPDF
tell application "Acrobat Distiller"
properties
Distill sourcePath (POSIX path of aliasFile) destinationPath strDistilleroutDir adobePDFSettingsPath theResponse
end tell
###OUTフォルダを開く
tell application "Finder"
make new Finder window to (aliasDistilleroutDir)
end tell

|

[Distiller]PSファイルをPDFに変換する

ポイントは

tell application "Acrobat Distiller"
properties
Distill sourcePathPsファイルのパスdestinationPath 出力先のディレクトリ adobePDFSettingsPath joboptionのパス
end tell

ダウンロード - distps2pdf.scpt.zip


#!/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



###Acrobat Distillerフォルダを作る
tell application "Finder"
set aliasShared to path to shared documents from user domain
set boolFolderExists to (exists of (folder "Acrobat Distiller" of folder aliasShared)) as boolean
if boolFolderExists is false then
make new folder at aliasShared with properties {name:"Acrobat Distiller", owner privileges:"read write", group privileges:"read write", everyones privileges:"read write", comment:"このフォルダはAcrobat Distiller用のフォルダです", description:"スクリプトが生成したフォルダです", label index:3}
end if
set aliasDistillerDir to folder "Acrobat Distiller" of folder aliasShared as alias
set strDistillerDir to POSIX path of aliasDistillerDir as text
end tell
###inフォルダを作る
tell application "Finder"
set boolFolderExists to (exists of (folder "in" of folder aliasDistillerDir)) as boolean
if boolFolderExists is false then
make new folder at aliasDistillerDir with properties {name:"in", owner privileges:"read write", group privileges:"read write", everyones privileges:"read write", comment:"このフォルダはAcrobat Distiller用のフォルダです", description:"スクリプトが生成したフォルダです", label index:3}
end if
set aliasDistillerInDir to folder "in" of folder aliasDistillerDir as alias
set strDistillerInDir to POSIX path of aliasDistillerInDir as text
end tell
###outフォルダを作る
tell application "Finder"
set boolFolderExists to (exists of (folder "out" of folder aliasDistillerDir)) as boolean
if boolFolderExists is false then
make new folder at aliasDistillerDir with properties {name:"out", owner privileges:"read write", group privileges:"read write", everyones privileges:"read write", comment:"このフォルダはAcrobat Distiller用のフォルダです", description:"スクリプトが生成したフォルダです", label index:3}
end if
set aliasDistilleroutDir to folder "out" of folder aliasDistillerDir as alias
set strDistilleroutDir to POSIX path of aliasDistilleroutDir as text
end tell
###ファイルを選択
set aliasFile to (choose file with prompt "PSファイルを選んでください" default location aliasDistillerDir of type {"com.adobe.postscript"} without invisibles, showing package contents and multiple selections allowed) as alias

###Print.joboptionsの一覧を取得
set strCommandText to ("ls -d /Library/Application\\ Support/Adobe/Adobe\\ PDF/Settings/*")
set strJobOption to do shell script strCommandText
set AppleScript's text item delimiters to "\r"
set listJobOption to every text item of strJobOption

###Print.joboptionsを選択
try
set objResponse to (choose from list listJobOption with title "Print.joboptions" with prompt "ジョブオプションを選んでください" default items (item 1 of listJobOption) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed)
on error
log "エラーしました"
return
end try
if objResponse is false then
return
end if
set theResponse to (objResponse) as text

###ディスティラでPDF
tell application "Acrobat Distiller"
properties
Distill sourcePath (POSIX path of aliasFile) destinationPath strDistilleroutDir adobePDFSettingsPath theResponse
end tell
###OUTフォルダを開く
tell application "Finder"
make new Finder window to (aliasDistilleroutDir)
end tell

|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat BookMark Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat Sequ Acrobat Sign Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe RemoteUpdateManager Apple AppleScript AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Audio AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript Guide AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript Mail AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFileManager enumeratorAtURL AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Events Plist AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML savedSearch AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript XMP AppleScript YouTube AppleScript Zero Suppress Applications CityCode Design github iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom