Print

[macOS13]CUPS2.3.4での混乱

Appleの気持ちはわかるのだが…
OSが認識するプリンタ
アプリケーションが認識するプリンタ
シェルでのプリンタ
CUPSからのプリンタがそれぞれバラバラで
トラブルってホドでは無いにしても、色々とサポートが必要になる場面が多い
例をあげると
システム設定のプリンタとスキャナが認識する『デフォルトの送信先』

CUPSが認識する『デフォルトの送信先』に相違が出る事がある
また
MDMからのmobileconfigによるデフォルト設定が入るとますます混乱の度を増す

AppleはCUPSヤメたいんだろうなぁとは思うけど
だいぶPDFになったとはいえ、まだまだPostScriptも必要だろうから
あと3年ぐらいは、この混乱は続くのだろう…

プリンタ設定、トラブルや不具合感じたら『リセット』して
その都度作り直しが、現時点では良さそう

|

[Print]キーノートとパワーポイントのデフォルト用紙サイズをカスタム用紙サイズに追加

Screencapture_1310x964_202111211424442


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


(************************************************************************

     この上の▶︎をぽっちっとしてください
PPDファイルの用紙サイズを
カスタム用紙サイズに登録します
パワーポイントのデフォルト用紙サイズPowerPoint(960x540)
キーノートのデフォルト用紙サイズKeyNote(1920x1080)

************************************************************************)


set theTop to (0) as real
set theLeft to (0) as real
set theRight to (0) as real
set theBottom to (0) as real
set thePrinter to " " as text
set theCustom to "TRUE" as text


(*###########defaults write com.apple.print.custompapers*)
set theDictName to "PowerPoint(960x540)" as text
set theName to "PowerPoint(960x540)" as text
set theId to "PowerPoint(960x540)" as text
set theWidth to "960" as number
set theHeight to "540" as number

-----theName
set theNameCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add name -string \"" & theName & "\"" as text
do shell script theNameCom
-----theId
set theIdCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add id -string \"" & theId & "\"" as text
do shell script theIdCom
-----height
set theHeightCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add height -float " & theHeight & "" as text
do shell script theHeightCom
-----width
set theWidthCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add width -float " & theWidth & "" as text
do shell script theWidthCom
-----Printer
set thePrinterCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add printer -string \"" & thePrinter & "\"" as text
do shell script thePrinterCom
-----Custom
set theCustomCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add custom -bool " & theCustom & "" as text
do shell script theCustomCom
-----top
set theTopCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add top -float " & theTop & "" as text
do shell script theTopCom
-----bottom
set theBottomCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add bottom -float " & theBottom & "" as text
do shell script theBottomCom
-----left
set theLeftCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add left -float " & theLeft & "" as text
do shell script theLeftCom
-----right
set theRightCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add right -float " & theRight & "" as text
do shell script theRightCom




(*###########defaults write com.apple.print.custompapers*)
set theDictName to "KeyNote(1920x1080)" as text
set theName to "KeyNote(1920x1080)" as text
set theId to "KeyNote(1920x1080)" as text
set theWidth to "1920" as number
set theHeight to "1080" as number

-----theName
set theNameCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add name -string \"" & theName & "\"" as text
do shell script theNameCom
-----theId
set theIdCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add id -string \"" & theId & "\"" as text
do shell script theIdCom
-----height
set theHeightCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add height -float " & theHeight & "" as text
do shell script theHeightCom
-----width
set theWidthCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add width -float " & theWidth & "" as text
do shell script theWidthCom
-----Printer
set thePrinterCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add printer -string \"" & thePrinter & "\"" as text
do shell script thePrinterCom
-----Custom
set theCustomCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add custom -bool " & theCustom & "" as text
do shell script theCustomCom
-----top
set theTopCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add top -float " & theTop & "" as text
do shell script theTopCom
-----bottom
set theBottomCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add bottom -float " & theBottom & "" as text
do shell script theBottomCom
-----left
set theLeftCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add left -float " & theLeft & "" as text
do shell script theLeftCom
-----right
set theRightCom to "defaults write com.apple.print.custompapers \"" & theDictName & "\" -dict-add right -float " & theRight & "" as text
do shell script theRightCom


set theCommandText to ("open \"/System/Library/PreferencePanes/PrintAndScan.prefPane\"") as text
do shell script theCommandText



display notification "処理終了" with title "処理が終了" subtitle "処理が終了しました" sound name "Sonumi"


log "\r\r>>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<\r\r"
"\r\r>>>>>>>>>>>>終了しました<<<<<<<<<<<<<<<\r\r"

|

プリンターCUPSのリセット

/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Versions/A/printtool --reset -f

この1文でリセットされますが
そこは、ホラねぇ それじゃあツマらんって事で

ジョブの削除
キューの削除してからの
リセットにしました

ダウンロード - printerreset.zip

(************************************************************************

     この上の▶︎をぽっちっとしてください

プリンターをリセットしいます
(全てのプリンタのジョブを削除してからプリンタを削除後にリセットの念の入れよう
************************************************************************)


set theComandText to ("lpstat -a | awk '{print $1}'") as text
set thePrinterList to (do shell script theComandText) as text
set AppleScript's text item delimiters to "\r"
set listPrinterList to (every text item of thePrinterList) as list
set AppleScript's text item delimiters to ""
set numPrinterNo to (count of listPrinterList) as integer
set numChkPrinter to 1 as integer

repeat numPrinterNo times

set thePrinter to (item numChkPrinter of listPrinterList) as text

try
set theComandText to ("lprm -P \"" & thePrinter & "\"") as text
do shell script theComandText
end try
try
set theComandText to ("lpadmin -x \"" & thePrinter & "\"") as text
do shell script theComandText
end try
set numChkPrinter to numChkPrinter + 1 as integer
end repeat


set theComandText to ("/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Versions/A/printtool --reset -f") as text
do shell script theComandText

display notification "処理終了" with title "処理が終了" subtitle "処理が終了しました" sound name "Sonumi"


log "\r\r>>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<\r\r"
"\r\r>>>>>>>>>>>>終了しました<<<<<<<<<<<<<<<\r\r"



log "\r\r>>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<\r\r"
"\r\r>>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<\r\r"


同じ事を
BASH
#!/bin/bash


ORG_IFS=$IFS
theQueList=`lpstat -a | awk '{print $1}'`


IFS=$'\n'

for theQueName in $theQueList;do
echo $theQueName
lprm -P $theQueName
done

for theQueName in $theQueList;do
lpadmin -x $theQueName
done
IFS=$ORG_IFS

/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Versions/A/printtool --reset -f

exit

同じ事を
zsh

#!/bin/zsh
#


local ORG_IFS=$IFS
theQueList=`lpstat -a | awk '{print $1}'`


local IFS=$'\n'
setopt sh_word_split

for theQueName in $theQueList;do
echo $theQueName
lprm -P $theQueName
done

for theQueName in $theQueList;do
lpadmin -x $theQueName
done
local IFS=$ORG_IFS

/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Versions/A/printtool --reset -f

exit




余談
たのむから『見た通り』の『表示』にしてくれんかな…
Screencapture_1804x826_20211104105342

|

PostScriptとサイズの数値の丸めの違い

MacOS標準のPSファイルをPDFに変換するのは
/usr/bin/pstopdf が担っている。

元になるPSファイルは
Screencapture-20210704-224655
このように
小数点11桁まで持っていますが



psファイルを『プレビュー』で開くと
Screencapture-20210704-224742
こんな感じで
サイズの値が丸られます



/usr/bin/pstopdf で作成したPDFも同様に
Screencapture-20210704-225158
サイズの丸めが発生します



psファイルをAcrobatにドラッグで作成したPDFは
Screencapture_20210704_22_47_16

こんな感じで、ちょっと独特なサイズの丸め感
小数点以下の話なので、どっちが良いか?って事でも無いですが
細い線を扱う場合は留意が必要『かも』しれません
この件はつづく

|

[AppleScripts]PS書出し用のバーチャルプリンタを追加する(簡易版)

[AppleScripts]PS書出し用のバーチャルプリンタを追加するのユーザーアクセス権版
↑のスクリプトは管理者権限が必要なので
せっかくプリンタはユーザーアクセス権のみで追加できますから
便利に使ってもらいたいと思います
AcrobatのPSプリンタの良い点は
ポイントは『余白0』のPSを作れる点です。












---ログ画面を開く

tell application "Script Editor"
tell application "System Events"
key code "37" using {command down, option down}
end tell
end tell

--ダウンロードするPPD

set thePPDsFile to "https://force4u.cocolog-nifty.com/skywalker/files/ppds.zip"

--ppdの保存先はユーザーの書類フォルダ内
set aliasUserDocumentsFolder to the path to documents folder from user domain as alias
set theUserDocumentsFolder to (POSIX path of aliasUserDocumentsFolder) as text


-----PPDの保存先を作る
try
set theCommand to ("mkdir -p " & theUserDocumentsFolder & "Printers") as text
do shell script theCommand
delay 1
on error
return "【エラー】テンポラリフォルダ作成でエラーが発生しました"
end try


-----ファイルをダウンロード
try
set theCommand to ("curl -o '" & theUserDocumentsFolder & "Printers/ppds.zip' '" & thePPDsFile & "'") as text
do shell script theCommand
delay 1
on error
return "【エラー】ダウンロードでエラーが発生しました"
end try


-----ファイルを解凍
try
set theCommand to ("unzip '" & theUserDocumentsFolder & "Printers/ppds.zip' -d '" & theUserDocumentsFolder & "Printers/' && rm '" & theUserDocumentsFolder & "Printers/ppds.zip'") as text
do shell script theCommand
delay 1


on error
do shell script "open '" & theUserDocumentsFolder & "Printers'"
return "【エラー】ファイルの解凍でエラーが発生しました\rppds.zipPPDsフォルダを\r削除してから再実行してください"
end try

----プリンタ作成 Acrobat

try
do shell script "lpadmin -D \"Acrobat PS Printer\" -L \"http://localhost:631/printers/AcrobatPsPrinter\" -p \"AcrobatPsPrinter\" -E -v \"lpd://localhost/Acrobat\" -P \"" & theUserDocumentsFolder & "Printers/PPDs/DS TRUEFLOW_J V1.4\" -o printer-is-shared=false"
delay 1
do shell script "cupsdisable \"AcrobatPsPrinter\""
on error
return "【エラー】プリンタ設定時にエラーが発生しました"
end try

----プリンタ作成 Trueflow
try
do shell script "lpadmin -D \"Ds Trueflow PS Printer\" -L \"http://localhost:631/printers/DsTrueflowPsPrinter\" -p \"DsTrueflowPsPrinter\" -E -v \"lpd://localhost/DsTrueflow\" -P \"" & theUserDocumentsFolder & "Printers/PPDs/DS TRUEFLOW_J V1.4\" -o printer-is-shared=false"
delay 1
do shell script "cupsdisable \"DsTrueflowPsPrinter\""
on error


return "【エラー】プリンタ設定時にエラーが発生しました"
end try


---システム環境設定を開く

try
tell application "System Preferences"
launch
activate
set current pane to pane id "com.apple.preference.printfax"
delay 2
tell current pane
tell application "System Events"
key code "48"
end tell
delay 1
tell application "System Events"
keystroke "Acrobat PS Printer"
end tell
end tell
end tell
end try



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




PPDは書類フォルダに
Screencapture_20210703_13_50_03



プリンタが追加されたのを確認してくださいまし
Screencapture_20210703_14_07_27

|

【システム環境設定】プリンタとスキャナ


try
set theComand to ("open \"x-apple.systempreferences:com.apple.preference.printfax\"") as text
do shell script theComand
(*
com.apple.preference.printfaxは有効ではないので
apple.systempreferencesが開いて終わり
*)
end try

----一般的にはこちらの記述が良いのか?と思います
try
tell application "System Preferences"
launch
activate
set current pane to pane id "com.apple.preference.printfax"
end tell
on error
set theComand to ("open \"/System/Library/PreferencePanes/PrintAndScan.prefPane\"") as text
do shell script theComand
end try

----com.apple.preference.printfaxのアンカーは4つ
tell application "System Preferences"
launch
activate
set current pane to pane id "com.apple.preference.printfax"
properties
tell current pane
properties
set theAnchors to get name of anchors
end tell
end tell

set theComand to ("open \"x-apple.systempreferences:com.apple.preference.printfax?scan\"") as text
do shell script theComand

set theComand to ("open \"x-apple.systempreferences:com.apple.preference.printfax?fax\"") as text
do shell script theComand

set theComand to ("open \"x-apple.systempreferences:com.apple.preference.printfax?print\"") as text
do shell script theComand

set theComand to ("open \"x-apple.systempreferences:com.apple.preference.printfax?share\"") as text
do shell script theComand



プリンタとスキャナ.scpt.zip

|

[AppleScripts]PS書出し用のバーチャルプリンタを追加する

今の現場では、在宅の方が数名いまして…
ルーター介しての設定が出来ていない部分もあり(あぁ〜後の祭り…)
各種設定等をスクリプトで対応せざるをえなかったりして…トホホ

AppleScriptでAcrobat9のPPDをダウンロード
PS書き出し用のバーチャルプリンタを設定します
※Acrobat9のPPDは余白0なので必要な場合も結構あります

※このスクリプトの設定部2を選択する場合は、ちょっちマニアックですので自己責任で…笑

追加されるプリンタは以下
 

Website_image00280107_232412
 

office系アプリから中国語等を作成する時に
仕上がりPDFが文字化けしちゃう場合
正しいPPDを設定が役に立つ『時』もあります
 

追加すると、Aiの印刷メニューからAcrobatPPDが選択出来るようになります
 
 
 


Website_image00280107_232632

 

Website_image00280107_232642
 

Website_image00280107_232714
 
 
中国系の用紙サイズの設定はありませんが
それでも、フォント指定は日本語用のPPDを使うより良いでしょう
 
 


Website_image00280107_235255

(*
MakeVirtualPrinter.scpt
20160106初回作成
現時点では10.6.8のみ正常確認済

Acrobat9ppdをインストールして
PS書出し用のバーチャルルプリンタを各言語毎に追加します。

*)

-------設定ここから
--【設定項目】重要です良く読んでね
(*
セキュリティに関わります2を選ぶ場合は自己責任で
1:デフォルト値:spoolのアクセス権を操作しません。
2:マニア向け:CUPSのスプールディレクトリをアクセス可能にして
ユーザーディレクトリにシンボリックリンクを作成します
その後でログインユーザーをPrint Operatorグループに追加します

*)
---12を設定
set numSpoolPerm to 1 as number
-------設定ここまで



---System Eventsを起動しておく
tell application "System Events"
launch
end tell
---ログを表示
tell application "AppleScript Editor"
activate
try
tell application "System Events" to keystroke "3" using {command down}
end try
try
tell application "System Events" to keystroke "l" using {option down, command down}
end try
end tell
---ユーザー名を取得する
set objSysInfo to system info
set theUserName to (short user name of objSysInfo) as text
----これはついで
try
do shell script "chflags nohidden ~/Library"
end try
---日付けと時間からテンポラリー用のフォルダ名を作成
set theNowTime to (my doDateAndTIme(current date)) as text
---テンポラリー用フォルダのパスを定義
set theTrashDir to ("/tmp/" & theNowTime) as text
-----テンポラリーフォルダを作成
try
set theCommand to ("mkdir -pv " & theTrashDir) as text
do shell script theCommand
set theTmpPath to theTrashDir as text
delay 1
on error
return "【エラー】テンポラリフォルダ作成でエラーが発生しました"
end try
-----ファイルをダウンロード
try
set theCommand to ("curl -o '" & theTmpPath & "/ppdfiles.zip' 'https://force4u.cocolog-nifty.com/file/ppdfiles.zip'") as text
do shell script theCommand
delay 1
on error
return "【エラー】ダウンロードでエラーが発生しました"
end try
-----ファイルを解凍
try
set theCommand to ("unzip '" & theTmpPath & "/ppdfiles.zip' -d '" & theTmpPath & "'") as text
do shell script theCommand
delay 1
on error
return "【エラー】ファイルの解凍でエラーが発生しました"
end try
-----インストール先のフォルダを確保
try
set theCommand to ("sudo mkdir -p '/Library/Printers/PPDs/Contents/Resources/VirtualPrinter'") as text
do shell script theCommand with administrator privileges
on error
----ここはエラー制御無しで
end try
-----ファイルを移動(おきかえ)
try
set theCommand to ("sudo mv -f " & theTmpPath & "/ppdfiles/* '/Library/Printers/PPDs/Contents/Resources/VirtualPrinter'") as text
do shell script theCommand with administrator privileges
on error
---ここはエラー制御無しでOKかな
end try
----アクセス権設定
try
set theCommand to ("sudo chmod 777 '/Library/Printers/PPDs/Contents/Resources/VirtualPrinter'") as text
do shell script theCommand with administrator privileges
set theCommand to ("sudo chmod 666 /Library/Printers/PPDs/Contents/Resources/VirtualPrinter/*") as text
do shell script theCommand with administrator privileges

on error
---ここはエラー制御無しでOKかな
end try
----初期化
set thePrinterStat to "\r"
----プリンターリストを取得
set thePrinterStat to (do shell script "lpstat -p | awk '{print $2}'") as text
---改行コード整形
set thePrinterStat to doReplace(thePrinterStat, "\r\r", "\r") as text
-------1行づつ処理するために改行で区切りリストにする
set AppleScript's text item delimiters to {"\r"}
---プリントキュー毎にリストにする
set thePrinterStatlist to (every text item of thePrinterStat) as list
---プリンタの台数を確定
set numPrinter to count of thePrinterStatlist
---処理番号リセット
set numPrinterNo to 1 as number
---繰り返しの始まり
repeat numPrinter times
----処理するキューを確定
set thePrinterQue to (item numPrinterNo of thePrinterStatlist) as text
---ここの2重トライは不要か?
try
try
------キューを空にする
if thePrinterQue is not "" then
do shell script "lprm -P " & thePrinterQue & ""
end if
end try
on error
exit repeat
end try
---カウントアップ
set numPrinterNo to (numPrinterNo + 1) as number
end repeat
------プリンターの削除
try
do shell script "lpadmin -x VrPriAcro9EN"
do shell script "lpadmin -x VrPriAcro9JP"
do shell script "lpadmin -x VrPriAcro9CS"
do shell script "lpadmin -x VrPriAcro9CT"
do shell script "lpadmin -x VrPriAcro9KR"
do shell script "lpadmin -x VrPriDsTrueflow"
end try
---プリンターアプリを削除
try
set theUserPath to ("/Users/" & theUserName & "/Library/Printers/VrPriAcro9EN") as text
do shell script "rm -Rf " & theUserPath & ""
set theUserPath to ("/Users/" & theUserName & "/Library/Printers/VrPriAcro9JP") as text
do shell script "rm -Rf " & theUserPath & ""
set theUserPath to ("/Users/" & theUserName & "/Library/Printers/VrPriAcro9CS") as text
do shell script "rm -Rf " & theUserPath & ""
set theUserPath to ("/Users/" & theUserName & "/Library/Printers/VrPriAcro9CT") as text
do shell script "rm -Rf " & theUserPath & ""
set theUserPath to ("/Users/" & theUserName & "/Library/Printers/VrPriAcro9KR") as text
do shell script "rm -Rf " & theUserPath & ""
set theUserPath to ("/Users/" & theUserName & "/Library/Printers/VrPriDsTrueflow") as text
do shell script "rm -Rf " & theUserPath & ""
end try
---ここからプリンタ登録
------------------------VrPriAcro9EN
try
---プリンタを登録
do shell script "lpadmin -p \"VrPriAcro9EN\" -E -v lpd://localhost/VrPriAcro9EN -P \"/Library/Printers/PPDs/Contents/Resources/VirtualPrinter/ADPDF9.PPD\" -D \"Acrobat9PpdPrinterEN\" -L \"Adobe PDF 9 Roman(バーチャル・プリンタ)\" -o printer-is-shared=false"
---印刷は出来ないので停止させる
do shell script "cupsdisable \"VrPriAcro9EN\""
on error
---エラーメッセージ
set Mes to "【エラー】VrPriAcro9ENでエラーがになりました\nパスワードをご確認ください" as text
return Mes
end try
------------------------VrPriAcro9JP
try
---プリンタを登録
do shell script "lpadmin -p \"VrPriAcro9JP\" -E -v lpd://localhost/VrPriAcro9JP -P \"/Library/Printers/PPDs/Contents/Resources/VirtualPrinter/ADPDF9J.PPD\" -D \"Acrobat9PpdPrinterJP\" -L \"Adobe PDF 9 Japanese(日本語バーチャル・プリンタ)\" -o printer-is-shared=false"
---印刷は出来ないので停止させる
do shell script "cupsdisable \"VrPriAcro9JP\""
on error
---エラーメッセージ
set Mes to "【エラー】VrPriAcro9JPでエラーがになりました\nパスワードをご確認ください" as text
return Mes
end try
------------------------VrPriAcro9CS
try
---プリンタを登録
do shell script "lpadmin -p \"VrPriAcro9CS\" -E -v lpd://localhost/VrPriAcro9CS -P \"/Library/Printers/PPDs/Contents/Resources/VirtualPrinter/ADPDF9CS.PPD\" -D \"Acrobat9PpdPrinterCS\" -L \"Adobe PDF 9 Simplified Chinese(簡体字・北京語バーチャル・プリンタ)\" -o printer-is-shared=false"
---印刷は出来ないので停止させる
do shell script "cupsdisable \"VrPriAcro9CS\""
on error
---エラーメッセージ
set Mes to "【エラー】VrPriAcro9CSでエラーがになりました\nパスワードをご確認ください" as text
return Mes
end try

------------------------VrPriAcro9CT
try
---プリンタを登録
do shell script "lpadmin -p \"VrPriAcro9CT\" -E -v lpd://localhost/VrPriAcro9CT -P \"/Library/Printers/PPDs/Contents/Resources/VirtualPrinter/ADPDF9CT.PPD\" -D \"Acrobat9PpdPrinterCT\" -L \"Adobe PDF 9 Traditional Chinese(繁体字・台湾語バーチャル・プリンタ)\" -o printer-is-shared=false"
---印刷は出来ないので停止させる
do shell script "cupsdisable \"VrPriAcro9CT\""
on error
---エラーメッセージ
set Mes to "【エラー】VrPriAcro9CTでエラーがになりました\nパスワードをご確認ください" as text
return Mes
end try
------------------------VrPriAcro9KR
try
---プリンタを登録
do shell script "lpadmin -p \"VrPriAcro9KR\" -E -v lpd://localhost/VrPriAcro9KR -P \"/Library/Printers/PPDs/Contents/Resources/VirtualPrinter/ADPDF9K.PPD\" -D \"Acrobat9PpdPrinterKR\" -L \"Adobe PDF 9 Korean(ハングル・韓国語バーチャル・プリンタ)\" -o printer-is-shared=false"
---印刷は出来ないので停止させる
do shell script "cupsdisable \"VrPriAcro9KR\""
on error
---エラーメッセージ
set Mes to "【エラー】VrPriAcro9KRでエラーがになりました\nパスワードをご確認ください" as text
return Mes
end try
------------------------VrPriDsTrueflow
try
---プリンタを登録
do shell script "lpadmin -p \"VrPriDsTrueflow\" -E -v lpd://localhost/VrPriDsTrueflow -P \"/Library/Printers/PPDs/Contents/Resources/VirtualPrinter/DS TRUEFLOW_J V1.4\" -D \"DsTrueflowPpdPrinter\" -L \"DS TRUEFLOW_J V1.4(バーチャル・プリンタ)\" -o printer-is-shared=false"
---印刷は出来ないので停止させる
do shell script "cupsdisable \"VrPriDsTrueflow\""
on error
---エラーメッセージ
set Mes to "【エラー】VrPriDsTrueflowでエラーがになりました\nパスワードをご確認ください" as text
return Mes
end try
-----WEBインターフェイスを有効にする
try
do shell script "cupsctl WebInterface=yes"
end try
-----SPOOLディレクトリのアクセス権設定他マニア向き
if numSpoolPerm is 2 then
----ログインユーザーをPrint Operatorグループに追加する
try
set theCommand to ("sudo dseditgroup -o edit -a " & theUserName & " -t user '_lp'") as text
do shell script theCommand with administrator privileges
delay 0.5
end try
----ログインユーザーをPrint Adminグループに追加する
try
set theCommand to ("sudo dseditgroup -o edit -a " & theUserName & " -t user '_lpadmin'") as text
do shell script theCommand with administrator privileges
delay 0.5
end try
----ログインユーザーをPrint Adminグループに追加する
try
set theCommand to ("sudo dseditgroup -o edit -a " & theUserName & " -t user '_lpoperator'") as text
do shell script theCommand with administrator privileges
delay 0.5
end try
try
set theCommand to ("ln -s '/private/var/spool/cups' '/Users/" & theUserName & "/CUPS'") as text
do shell script theCommand with administrator privileges
end try
----SPOOLディレクトリのアクセス権設定
try
do shell script "sudo chmod -f 777 '/private/var/spool'" with administrator privileges
delay 0.5
end try
try
do shell script "sudo chmod -f 777 '/private/var/spool/cups'" with administrator privileges
delay 0.5
end try
end if

----システム環境設定のプリンタを開く
tell application "Finder"
activate
try
do shell script "open /System/Library/PreferencePanes/PrintAndScan.prefPane"
on error
try
do shell script "open /System/Library/PreferencePanes/PrintAndFax.prefPane"
end try
end try
end tell
----CUPSWEBインターフェイスを開く
set theUrl to "http://localhost:631/printers/" as text
set appName to "Safari"
tell application "Safari"
activate
make new document
tell window 1
open location theUrl
end tell
end tell
---終了メッセージ
set Mes to "処理は終了しました。\n" as text
return Mes




--------------------------------------------------#ここからサブルーチン
to doDateAndTIme(theDate)
set y to (year of theDate)
set m to my monthNumStr(month of theDate)
set d to day of theDate
set hms to time of theDate
set hh to h of sec2hms(hms)
set mm to m of sec2hms(hms)
set ss to s of sec2hms(hms)
return (y as text) & my zero1(m) & my zero1(d) & "_" & zero1(hh) & zero1(mm) & zero1(ss)
return (y as text) & my zero1(m) & my zero1(d)
end doDateAndTIme

------------------------------
to monthNumStr(theMonth)
set monList to {January, February, March, April, May, June, July, August, September, October, November, December}
repeat with i from 1 to 12
if item i of monList is theMonth then exit repeat
end repeat
return i
end monthNumStr
------------------------------
to sec2hms(sec)
set ret to {h:0, m:0, s:0}
set h of ret to sec div hours
set m of ret to (sec - (h of ret) * hours) div minutes
set s of ret to sec mod minutes
return ret
end sec2hms
------------------------------
to zero1(n)
if n < 10 then
return "0" & n
else
return n as text
end if
end zero1
------------------------------文字の置き換えのサブルーチン
to doReplace(theText, orgStr, newstr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newstr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace


「MakeVirtualPrinter.scpt.zip」をダウンロード

ソースはこちら
https://github.com/force4u/MakeVirtualPrinter.scpt/blob/master/MakeVirtualPrinter.scpt

「MakeVirtualPrinter.scpt.zip」をダウンロード

 
  
 
追加されるプリンターは
印刷出来ない(PS書き出し専用なので)ので
全て『停止』状態で登録されます。

 
Website_image00280106_210343

 

|

CUPS-PDF


ドイツ産?
CUPS-PDF
最新は3.0のβです
http://www.cups-pdf.de/

Website_image00260630_233610


Mac版のパッケージは
こちら
https://bitbucket.org/codepoet/cups-pdf-for-mac-os-x/downloads

Website_image00260630_233248


インストールは普通に
追加で
PPDはお好みで

Website_image00260630_233445

ちなみに
ACROBAT9のPPDはこちら

Website_image00260630_234610


/Applications/Adobe\ Acrobat 9 Pro/Adobe Acrobat Pro.app/Contents/MacOS/SelfHealFiles/AdobePDFPrinter/PPDs/Contents/Resources/ja.lproj/ADPDF9J.PPD

Acrobat9が無い人は
こちら
http://helpx.adobe.com/acrobat/kb/acrobat-8-9-product-downloads.html
からインストールする…

Website_image00260630_234921


|

[AppleScript]com.apple.print.custompapersにカスタム用紙サイズを登録する

defaults write com.apple.print.custompapers で
カスタム用紙サイズを作成します

手順は以下

1:エクセルで用紙サイズリストを作成します
2:タブ区切りテキストで保存します
3:スクリプトを実行します


こんな感じのエクセルの表を

Comappleprintcustompapers002


タブ区切りテキストでかき出して

Comappleprintcustompapers003


スクリプトを実行すると
カスタム用紙サイズをババっと登録できます

Comappleprintcustompapers001


(*
タブ区切りテキスト内の
用紙サイズを「カスタム用紙」として登録します

【重要】インチサイズ専用
mm用を作成する場合は文中の換算部を変更すれば使えます
----inchpt換算部
set theHeight to (theHeight * 72) as text
set theWidth to (theWidth * 72) as text
----mmpt換算の場合

set theHeight to (theHeight * 2.8346456693) as text
set theWidth to (theWidth * 2.8346456693) as text


ユーザーの「preferences」フォルダに
com.apple.print.custompapers.backup フォルダを作ります
そこにカスタム用紙サイズファイルのバックアップを作成します
*)



on run

-----まずはバックアップを作成
-----初期設定までのパスを取得
set theUserPrefDirName to (path to preferences folder from user domain) as text
-----バックアップフォルダを作成
tell application "Finder"
try
make new folder at theUserPrefDirName with properties {name:"com.apple.print.custompapers.backup"}
end try
end tell
-----ファイル名やらディレクトリ名やら
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'"
set theNewFileName to ("com.apple.print.custompapers.plist." & theTime) 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

----本処理スタート

------------プロンプトの文言改行が使えます\nを入れます
set theWithPrompt to "用紙サイズタブテキストからカスタム用紙サイズを作成します\n"
------------ファイル選択ダイアログのデフォルトのディレクトリ
tell application "Finder"
set theDefaultLocation to (container of (path to me)) as alias
end tell
------------Uniform Type Identifier指定
set theFileTypeList to "public.plain-text,com.apple.traditional-mac-plain-text" as text
------------のファイルタイプをリスト形式に整形する
set AppleScript's text item delimiters to {","}
set theFileTypeList to every text item of theFileTypeList
------------ダイアログを出して選択されたファイルは「open」に渡す
open (choose file default location theDefaultLocation ¬
with prompt theWithPrompt ¬
of type theFileTypeList ¬
invisibles true ¬
with multiple selections allowed without showing package contents)
end run

on open objOpen
------元々エイリアスだけどお約束で
set theFileAlias to objOpen as alias
------選択したファイルのUNIXパスを取得
set theUnixPass to POSIX path of theFileAlias as text
-----選んだファイルを読み込む
set theData to (do shell script "cat '" & theUnixPass & "'") as «class utf8»


------改行毎にリストにする
set AppleScript's text item delimiters to {"\r"}
set retListData to (every text item of theData) as list
------リストに変更した後で項目数を数える
set numListLine to (count of retListData) as number
set numListLine to numListLine - 1 as number
---2行目から読み込むための初期化
set numLine to 2 as number

repeat numListLine times
-----初期化
set theBottom to "" as text
set theLeft to "" as text
set theRight to "" as text
set theTop to "" as text
set theId to "" as text
set theName to "" as text
set theId to "" as text
-----1行読み込む
set theDataListLine to (item numLine of retListData) as text
-----カンマがあれば取り除く
set theDataListLine to doReplace(theDataListLine, ",", "")
set AppleScript's text item delimiters to {"\t"}
-----タブ毎にリスト項目にする
set retListDataOfLine to (every text item of theDataListLine) as list
set AppleScript's text item delimiters to {""}
-----各項目を取り出す
set theName to (item 1 of retListDataOfLine) as text
set theWidth to (item 2 of retListDataOfLine) as number
set theHeight to (item 3 of retListDataOfLine) as number
set theTop to (item 4 of retListDataOfLine) as text
set theBottom to (item 5 of retListDataOfLine) as text
set theLeft to (item 6 of retListDataOfLine) as text
set theRight to (item 7 of retListDataOfLine) as text
-----固定項目 プリンターとカスタム用紙サイズ
set thePrinter to " " as text
set theCustom to "TRUE" as text
----inchpt換算部
set theHeight to (theHeight * 72) as text
set theWidth to (theWidth * 72) as text
----mmpt換算の場合
(*
set theHeight to (theHeight * 2.8346456693) as text
set theWidth to (theWidth * 2.8346456693) as text
*)
-----項目の値が空だった場合の処理
if theId is "" then
set theId to theName as text
else
set theId to theId as text
end if
if theTop is "" then
set theTop to "0" as text
else
set theTop to theTop as text
end if
if theBottom is "" then
set theBottom to "0" as text
else
set theBottom to theBottom as text
end if
if theLeft is "" then
set theLeft to "0" as text
else
set theLeft to theLeft as text
end if
if theRight is "" then
set theRight to "0" as text
else
set theRight to theRight as text
end if

--------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


-----カウントアップ
set numLine to numLine + 1 as number
end repeat




end open




--------------文字の置き換えサブルーチン
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


「Na_custompapers.rtf」をダウンロード

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

|

ドリームページ・プラス

【ドリームページ・プラス|DNPのフォトブック】


Source:【ドリームページ・プラス|DNPのフォトブック】

Source:ドリームページ・プラス|DNPのフォトブック

|

その他のカテゴリー

Accessibility AccessibilityCheck AccessibilityForm AccessibilityInDesign AccessibilityPDF Acrobat Acrobat Action Acrobat Annotation Acrobat AppleScripts Acrobat Character Acrobat Layer Acrobat PDF Embed API Acrobat PDF Form Print Acrobat Plug-ins Acrobat Portfolios Acrobat Print AcrobatBarcode AcrobatDialog AcrobatForm AcrobatJS AcrobatMenu AcrobatPDF AcrobatStamp AcrobatYouTube AddressBook Adobe Adobe InDesign Adobe Photoshop AdobeAppleScript AdobeBridge AdobeIllustrator AdobeJSX aed Alfresco Android AnimationGif Apple Apple Support AppleScript AppleScriptBasics AppleScriptCharacter AppleScriptColor AppleScriptDroplet AppleScriptErrorNum AppleScriptFolder AppleScriptFontBook AppleScriptRename AppleScriptTools AppleSymbols Applications Barcode Barcode2D BarcodePostal BetterHTMLExport Book BOX Browser buzz Certificates CharacterEntity CharacterSets Colors Cool Site CSS Cutting DecoMail DecorationMail Design Desktop Diff DJ dmg DNS Documents Download DTP eBook Editer eMail Envelopes ExifTool Facebook FFmpeg File System Fonts FontsTool FontsWeb FOOD FormPrint ftp Gadget Gif Animation Google Google Chrome Enterprise HexEditor HTML info iPhoto ISBN ISO iTunes iWork iWorkNumbers iWorkNumbersCalendar iWorkNumbersTimecard iWorkPages JavaScript JeditX JeditX Regexp JeditXAppleScript JIS jquery Letterpress Library logo Mac Admin Mac Archiver Mac Browser Mac Browser Plugin Mac QuickLook Mac Setup Mac Spotlight Mac Video Map Memo Microsoft Teams Mobby mobileconfig Moto Movies Music Network Basic ntp OCR Office OfficePowerPoint OSX Paint Pantone Paper PDFlib Permission Photo Pictograms Print Public Python QuickLook QuickTime QuickTimeSetting QuickTimeSound Real Media ReName ResourceFork ruby Sample Screen ScreenCast Search Security SEO Sharing SLAResource Sound Spotlight Stamp SWF TCC.db Tutorial PSD TV Twitter Typography Unicode Utilities Video WEB APP WebFont Wedding Windows WindowsMedia XML XMP XPS YouTube YouTube Rss