PostScript

Encapsulated PostScript File Format Specification.pdf

ダウンロード - encapsulated20postscript20file20format20specification.pdf


|

PostScript Language Document Structuring Conventions Specification.pdf

ダウンロード - postscript20language20document20structuring20conventions20specification.pdf


|

PostScript Language Reference Manual SECOND EDITION.pdf

ダウンロード - postscript20language20reference20manual20second20edition.pdf


|

PostScript Language Reference Manual third edition.pdf

ダウンロード - postscript20language20reference20manual20third20edition.pdf


|

[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

|

[macOS14]Postscript・eps(encapsulated-postscript)ファイルのPDF変換


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
(*
Inkscapeのインストールが必須になります
https://inkscape.org/release/1.3/mac-os-x/
Inkscape内臓の
Ghostscriptを利用してPSとEPSをPDFに変換します
*)
#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 strBundleID to "org.inkscape.Inkscape" 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 appFileManager to refMe's NSFileManager's defaultManager()
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", "com.adobe.postscript"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  set listAliasFilePath to (choose file strMes with prompt strPrompt default location aliasDefaultLocation of type listUTI with invisibles, multiple selections allowed and showing package contents) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if listAliasFilePath is {} then
return "選んでください"
end if



################################
###ダイアログ 変換PDFバージョン
set listPdfVer to {"ps2pdf", "ps2pdf12", "ps2pdf13", "ps2pdf14"}
###ダイアログ
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
try
  set listResponse to (choose from list listPdfVer with title "短め" with prompt "長め" default items (item 1 of listPdfVer) 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 "キャンセルしました"
else
  set strResponse to (item 1 of listResponse) as text
end if
################################
###バンドルIDからアプリケーションのインストール先を求める
set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strBundleID)
if ocidAppBundle is missing value then
  set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
  set ocidAppBundlePathURL to (appNSWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
else
  set ocidAppBundleStr to ocidAppBundle's bundlePath()
  set ocidAppBundlePath to ocidAppBundleStr's stringByStandardizingPath
  set ocidAppBundlePathURL to (refMe's NSURL's fileURLWithPath:(ocidAppBundlePath))
end if
if ocidAppBundlePathURL = (missing value) then
  tell application "Finder"
    try
      set aliasAppApth to (application file id strBundleID) as alias
    on error
return "アプリケーションが見つかりませんでした"
    end try
  end tell
  set strAppPath to POSIX path of aliasAppApth as text
  set ocidAppBundlePathStr to refMe's NSString's stringWithString:(strAppPath)
  set ocidAppBundlePath to ocidAppBundlePathStr's stringByStandardizingPath()
  set ocidAppBundlePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppBundlePath) isDirectory:true
end if
###コマンドのあるディレクトリ
set ocidBinDirPathURL to ocidAppBundlePathURL's URLByAppendingPathComponent:("Contents/Resources/bin/")
###ダイアログの戻り値を加えてバイナリへのパス
set ocidBinPathURL to ocidBinDirPathURL's URLByAppendingPathComponent:(strResponse)
set strBinPath to ocidBinPathURL's |path| as text
log strBinPath
################################
###本処理
repeat with itemAliasFilePath in listAliasFilePath
  ###パス
  set strFilePath to (POSIX path of itemAliasFilePath) as text
  set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
  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 ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
  set ocidFileName to ocidBaseFilePathURL's lastPathComponent()
  set ocidSaveFileName to (ocidFileName's stringByAppendingPathExtension:("pdf"))
  set ocidSaveFilePathURL to (ocidContainerDirPathURL's URLByAppendingPathComponent:(ocidSaveFileName))
  set strSaveFilePath to ocidSaveFilePathURL's |path| as text
  ###コマンド整形
  set strCommandText to ("\"" & strBinPath & "\" \"" & strFilePath & "\" \"" & strSaveFilePath & "\"") as text
  ##実行はターミナルで(エラーメッセージ出るからね)
  tell application "Terminal"
    launch
    activate
    set objWindowID to (do script "\n\n")
    delay 1
do script strCommandText in objWindowID
    delay 2
do script "\n\n" in objWindowID
    # do script "exit" in objWindowID
    # set theWid to get the id of window 1
    # delay 1
    # close front window saving no
  end tell
  
end repeat


|

EPSファイルを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 AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application


#######
###
(* pstopdfは
初回実行時に時間がかかる事から
事前に起動時に削除される形式で実行しておく
*)
set strInputPath to ("/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/images/logo.eps") as text
set strOutPutPath to ("/tmp/logo.eps.pdf") as text
####コマンドパス
set strBinPath to "/usr/bin/pstopdf"
#####コマンド整形
set strCommandText to ("\"" & strBinPath & "\"  \"" & strInputPath & "\" -o \"" & strOutPutPath & "\"") as text
do shell script strCommandText

#############################
#####ファイル選択ダイアログ
#############################
###ダイアログを前面に出す
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder"
    activate
  end tell
else
  tell current application
    activate
  end tell
end if
###ダイアログのデフォルト
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidUserDesktopPath to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set aliasDefaultLocation to ocidUserDesktopPath as alias
set listChooseFileUTI to {"com.adobe.encapsulated-postscript", "com.adobe.postscript"}
set strPromptText to "ファイルを選んでください" as text
set listAliasFilePath to (choose file with prompt strPromptText default location (aliasDefaultLocation) of type listChooseFileUTI with invisibles and multiple selections allowed without showing package contents) as list

############
set strMes to "保存先フォルダを選んでください" as text
set strPrompt to "保存先フォルダを選択してください" as text
try
  set aliasSaveDirPath to (choose folder strMes with prompt strPrompt default location aliasDefaultLocation without multiple selections allowed, invisibles and showing package contents) as alias
on error
  log "エラーしました"
return "エラーしました"
end try
set strSaveDirPath to (POSIX path of aliasSaveDirPath) as text
set ocidSaveDirPathStr to (refMe's NSString's stringWithString:(strSaveDirPath))
set ocidSaveDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveDirPathStr))

####複数ファイル対応
repeat with itemAliasFilePath in listAliasFilePath
  ###エイリアス
  set aliasFilePath to itemAliasFilePath as alias
  ###パステキスト
  set strFilePath to (POSIX path of aliasFilePath) as text
  ####入力ファイルパス確定
  set strInputFilePath to strFilePath as text
  ###パス
  set ocidFilePath to (refMe's NSString's stringWithString:(strFilePath))
  ###NSURL
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath))
  ###ファイル名
  set ocidFileName to ocidFilePathURL's lastPathComponent()
  ###拡張子を取ったベースファイル名
  set strBaseFileName to ocidFileName's stringByDeletingPathExtension() as text
  ####出力ファイル名
  set strNewFileName to (strBaseFileName & ".pdf") as text
  ####ディレクトリのURL
  set ocidSaveFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(strNewFileName))
  ####ファイルの有無チェック
  set boolFileExist to (ocidSaveFilePathURL's checkResourceIsReachableAndReturnError:(missing value)) as boolean
  ###すでに同名ファイルがある場合は日付時間入りのファイル名
  if boolFileExist is true then
    ####日付情報の取得
    set ocidDate to refMe's NSDate's |date|()
    ###日付のフォーマットを定義
    set ocidNSDateFormatter to refMe's NSDateFormatter's alloc()'s init()
(ocidNSDateFormatter's setDateFormat:"yyyyMMddhhmm")
    set ocidDateAndTime to (ocidNSDateFormatter's stringFromDate:(ocidDate))
    set strDateAndTime to ocidDateAndTime as text
    ####ファイル名に日付を入れる
    set strSaveFileName to (strBaseFileName & "." & strDateAndTime & ".pdf") as text
    set ocidSaveFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName))
      set strSaveFilePath to (ocidSaveFilePathURL's |path|()) as text
  else
    ####出力ファイルパス
    set strSaveFilePath to (ocidSaveFilePathURL's |path|()) as text
  end if
  ################################################
  ####コマンドパス
  set strBinPath to "/usr/bin/pstopdf"
  #####コマンド整形
  set strCommandText to ("\"" & strBinPath & "\"  \"" & strInputFilePath & "\" -o \"" & strSaveFilePath & "\"") as text
  do shell script strCommandText
  (* ターミナル使いたい場合はこちら
####ターミナルで開く
tell application "Terminal"
launch
activate
set objWindowID to (do script "\n\n")
delay 1
do script strCommandText in objWindowID
end tell
*)
end repeat




|

[PostScript]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
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()

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

############PPDファイルの有無チェック
if boolFileExists is true then
  log "PPDはインストール済み"
  set strPPDsFilePath to ocidPPDFilePathURL's |path|() as text
else
  ########################
  ###無い場合はダウンロード
  set ocidSaveDirPathURL to ocidUserPathURL's URLByAppendingPathComponent:"Shared/Library/Printers/PPDs/Contents/Resources/Acrobat" isDirectory:true
  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
#############################
#####ファイル選択ダイアログ
#############################
###ダイアログを前面に出す
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder"
    activate
  end tell
else
  tell current application
    activate
  end tell
end if
###ダイアログのデフォルト
set ocidUserDesktopPath to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set aliasDefaultLocation to ocidUserDesktopPath as alias
tell application "Finder"
  
end tell
set listChooseFileUTI to {"com.adobe.postscript"}
set strPromptText to "ファイルを選んでください" as text
set listAliasFilePath to (choose file with prompt strPromptText default location (aliasDefaultLocation) of type listChooseFileUTI with invisibles and multiple selections allowed without showing package contents) as list



repeat with itemAliasFilePath in listAliasFilePath
  ###エイリアス
  set aliasFilePath to itemAliasFilePath as alias
  ###パステキスト
  set strFilePath to (POSIX path of aliasFilePath) as text
  ####入力ファイルパス確定
  set strInputFilePath to strFilePath as text
  ###パス
  set ocidFilePath to (refMe's NSString's stringWithString:strFilePath)
  ###NSURL
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath)
  ###ファイル名
  set ocidFileName to ocidFilePathURL's lastPathComponent()
  ###拡張子を取ったベースファイル名
  set strBaseFileName to ocidFileName's stringByDeletingPathExtension() as text
  ####入力ファイルの1階層上のフォルダURL
  set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
  ####ディレクトリのURLコンポーネント
  set strContainerDirPath to ocidContainerDirPathURL's |path|() as text
  
  ####出力ファイル名
  set strNewFileName to (strBaseFileName & ".pdf") as text
  ####ディレクトリのURLコンポーネント
  set ocidNewFilePathURL to (ocidContainerDirPathURL's URLByAppendingPathComponent:strNewFileName)
  ####ファイルの有無チェック
  set boolFileExist to (ocidNewFilePathURL's checkResourceIsReachableAndReturnError:(missing value)) as boolean
  ###すでに同名ファイルがある場合は日付時間入りのファイル名
  if boolFileExist is true then
    ####日付情報の取得
    set ocidDate to refMe's NSDate's |date|()
    ###日付のフォーマットを定義
    set ocidNSDateFormatter to refMe's NSDateFormatter's alloc()'s init()
(ocidNSDateFormatter's setDateFormat:"yyyyMMdd-hhmm")
    set ocidDateAndTime to (ocidNSDateFormatter's stringFromDate:ocidDate)
    set strDateAndTime to ocidDateAndTime as text
    ####ファイル名に日付を入れる
    set strNewFilePath to (strContainerDirPath & "/" & strBaseFileName & "." & strDateAndTime & ".pdf") as text
  else
    ####出力ファイルパス
    set strNewFilePath to (strContainerDirPath & "/" & strNewFileName & "") as text
  end if
  ################################################
  ####コマンドパス
  set strBinPath to "/usr/sbin/cupsfilter"
  #####コマンド整形
  set strCommandText to ("\"" & strBinPath & "\" -f \"" & strInputFilePath & "\" -m \"application/pdf\" -p \"" & strPPDsFilePath & "\" -e -t \"" & strBaseFileName & "\" > \"" & strNewFilePath & "\"")
  ####ターミナルで開く
  tell application "Terminal"
    launch
    activate
    set objWindowID to (do script "\n\n")
    delay 1
do script strCommandText in objWindowID
  end tell
end repeat




|

[pstopdf]EPSと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
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()



#############################
#####ファイル選択ダイアログ
#############################
###ダイアログを前面に出す
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder"
    activate
  end tell
else
  tell current application
    activate
  end tell
end if
###ダイアログのデフォルト
set ocidUserDesktopPath to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set aliasDefaultLocation to ocidUserDesktopPath as alias
tell application "Finder"
  
end tell
set listChooseFileUTI to {"com.adobe.encapsulated-postscript", "com.adobe.postscript"}
set strPromptText to "ファイルを選んでください" as text
set listAliasFilePath to (choose file with prompt strPromptText default location (aliasDefaultLocation) of type listChooseFileUTI with invisibles and multiple selections allowed without showing package contents) as list



repeat with itemAliasFilePath in listAliasFilePath
  ###エイリアス
  set aliasFilePath to itemAliasFilePath as alias
  ###パステキスト
  set strFilePath to (POSIX path of aliasFilePath) as text
  ####入力ファイルパス確定
  set strInputFilePath to strFilePath as text
  ###パス
  set ocidFilePath to (refMe's NSString's stringWithString:strFilePath)
  ###NSURL
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath)
  ###ファイル名
  set ocidFileName to ocidFilePathURL's lastPathComponent()
  ###拡張子を取ったベースファイル名
  set strBaseFileName to ocidFileName's stringByDeletingPathExtension() as text
  ####入力ファイルの1階層上のフォルダURL
  set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
  ####ディレクトリのURLコンポーネント
  set strContainerDirPath to ocidContainerDirPathURL's |path|() as text
  
  ####出力ファイル名
  set strNewFileName to (strBaseFileName & ".pdf") as text
  ####ディレクトリのURLコンポーネント
  set ocidNewFilePathURL to (ocidContainerDirPathURL's URLByAppendingPathComponent:strNewFileName)
  ####ファイルの有無チェック
  set boolFileExist to (ocidNewFilePathURL's checkResourceIsReachableAndReturnError:(missing value)) as boolean
  ###すでに同名ファイルがある場合は日付時間入りのファイル名
  if boolFileExist is true then
    ####日付情報の取得
    set ocidDate to refMe's NSDate's |date|()
    ###日付のフォーマットを定義
    set ocidNSDateFormatter to refMe's NSDateFormatter's alloc()'s init()
    (ocidNSDateFormatter's setDateFormat:"yyyyMMdd-hhmm")
    set ocidDateAndTime to (ocidNSDateFormatter's stringFromDate:ocidDate)
    set strDateAndTime to ocidDateAndTime as text
    ####ファイル名に日付を入れる
    set strNewFilePath to (strContainerDirPath & "/" & strBaseFileName & "." & strDateAndTime & ".pdf") as text
  else
    ####出力ファイルパス
    set strNewFilePath to (strContainerDirPath & "/" & strNewFileName & "") as text
  end if
  ################################################
  ####コマンドパス  
  set strBinPath to "/usr/bin/pstopdf"
  #####コマンド整形
  set strCommandText to ("\"" & strBinPath & "\"  \"" & strInputFilePath & "\" -o \"" & strNewFilePath & "\"")
  ####ターミナルで開く
  tell application "Terminal"
    launch
    activate
    set objWindowID to (do script "\n\n")
    delay 1
    do script strCommandText in objWindowID
  end tell
end repeat



|

[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

|

より以前の記事一覧

その他のカテゴリー

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