AppleScript MakePDF

[MakePDF]まとめ

デジカメのデータを写真アプリにインポートする時に使う
イメージ・キャプチャーのおまけ的なアプリ
コンタクトシート生成がメイン。細かい設定は出来ないので
PDF集約で8in1(8up)したい時限定かな?使うのは
bridgeあるなら、不要だが余白0の集約が可能なのはポイント高い

Screen-20230908-134206

スクリプトとレイアウトデータの見本の詰め合わせ

ダウンロード - makepdf.zip

Screen-20230908-135123

それは…ピクセルでは無い…ptなんじゃぁ

|

[MakePDF]レイアウトを指定して開く(サンプルはA3横の8up 8in1コンタクトシート)


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

#!/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 "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application

set strBundleID to ("com.apple.MakePDF") as text

####終了させてから処理させる
tell application id strBundleID
  quit
end tell
####半ゾンビ対策
set ocidRunningApplication to refMe's NSRunningApplication
set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
end repeat

####開く時の設定を書き換える
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirURL to ocidURLsArray's firstObject()
set ocidPlistFilePathURL to ocidLibraryDirURL's URLByAppendingPathComponent:("Preferences/com.apple.MakePDF.plist")
set ocidLayoutDirPathURL to ocidLibraryDirURL's URLByAppendingPathComponent:("Application Support/Apple/MakePDF")
set ocidLayoutDirPath to ocidLayoutDirPathURL's |path|()
###PLIST読み込み
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL)
ocidPlistDict's setValue:(ocidLayoutDirPath) forKey:("lastOpenedDirectory")
###MakePDFlayout
set ocidLayoutDict to ocidPlistDict's objectForKey:("MakePDFlayout")
###設定
ocidLayoutDict's setValue:(refMe's NSNumber's numberWithInteger:0) forKey:("defaultBorder")
ocidLayoutDict's setValue:(refMe's NSNumber's numberWithInteger:0) forKey:("screenRes")
ocidLayoutDict's setValue:(refMe's NSNumber's numberWithBool:false) forKey:("imagesGetCropped")
ocidLayoutDict's setValue:(refMe's NSString's stringWithString:("A3横8in1")) forKey:("layoutName")
##用紙サイズ
ocidLayoutDict's setValue:(refMe's NSNumber's numberWithInteger:1191) forKey:("pageWidth")
ocidLayoutDict's setValue:(refMe's NSNumber's numberWithInteger:842) forKey:("pageHeight")
##集約内容のコマサイズ
ocidLayoutDict's setValue:(refMe's NSNumber's numberWithInteger:297) forKey:("defaultImageWide")
ocidLayoutDict's setValue:(refMe's NSNumber's numberWithInteger:421) forKey:("defaultImageHigh")
###保存
set boolDone to ocidPlistDict's writeToURL:(ocidPlistFilePathURL) atomically:true

#############################
###ダイアログ
tell current application
  set strName to name as text
end tell
###ダイアログを前面に出す
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
tell application "Finder"
  set aliasDefaultLocation to container of (path to me) as alias
  set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell
############
set strMes to "フォルダを選んでください" as text
set strPrompt to "フォルダを選択してください" as text
try
  set listAliasFolderPath to (choose folder strMes with prompt strPrompt default location aliasDefaultLocation with multiple selections allowed without invisibles and showing package contents)
on error
  log "エラーしました"
return "エラーしました"
end try

tell application id strBundleID to launch
repeat 10 times
  try
    tell application id strBundleID to activate
  end try
  set boolFontmost to frontmost of (application id strBundleID)
  if boolFontmost is false then
    delay 1
    tell application id strBundleID to launch
  else
    tell application id strBundleID to activate
    exit repeat
  end if
end repeat


repeat with objAliasFolderPath in listAliasFolderPath
  set aliasFolderPath to objAliasFolderPath as alias
  
  tell application id strBundleID to open aliasFolderPath
  
end repeat





|

[MakePDF]レイアウト(mkpdfファイルはPLIST)


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

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>defaultBorder</key>
  <integer>0</integer>
  <key>defaultImageHigh</key>
  <integer>415</integer>
  <key>defaultImageWide</key>
  <integer>290</integer>
  <key>dontOpenPDF</key>
  <integer>0</integer>
  <key>imagesGetCropped</key>
  <integer>1</integer>
  <key>layoutName</key>
  <string>A3横8up</string>
  <key>pageHeight</key>
  <integer>842</integer>
  <key>pageWidth</key>
  <integer>1191</integer>
  <key>screenRes</key>
  <integer>0</integer>
  <key>showsUI</key>
  <integer>0</integer>
  <key>version</key>
  <integer>2</integer>
</dict>
</plist>


|

MakePDF起動


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

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


set strBundleID to ("com.apple.MakePDF") as text

####終了させてから処理させる
tell application id strBundleID
  quit
end tell
####半ゾンビ対策
set ocidRunningApplication to refMe's NSRunningApplication
set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
end repeat
###起動
tell application id strBundleID to launch
repeat 10 times
  try
    tell application id strBundleID to activate
  end try
  set boolFontmost to frontmost of (application id strBundleID)
  if boolFontmost is false then
    delay 1
    tell application id strBundleID to launch
  else
    tell application id strBundleID to activate
    exit repeat
  end if
end repeat





|

[MakePDF]フォルダを開く


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

#!/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 "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application

set strBundleID to ("com.apple.MakePDF") as text

#############################
###ダイアログ
tell current application
  set strName to name as text
end tell
###ダイアログを前面に出す
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
tell application "Finder"
  set aliasDefaultLocation to container of (path to me) as alias
  set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell
############
set strMes to "フォルダを選んでください" as text
set strPrompt to "フォルダを選択してください" as text
try
  set listAliasFolderPath to (choose folder strMes with prompt strPrompt default location aliasDefaultLocation with multiple selections allowed without invisibles and showing package contents)
on error
  log "エラーしました"
return "エラーしました"
end try


tell application id strBundleID to launch
tell application id strBundleID to activate


repeat with objAliasFolderPath in listAliasFolderPath
  set aliasFolderPath to objAliasFolderPath as alias
  
  tell application id strBundleID to open aliasFolderPath
  
end repeat





|

[MakePDF]レイアウトの保存先


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# PDFlayout 拡張子 mkpdfファイルの保存先を開く
#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 ("com.apple.MakePDF") as text

set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidSupportDirPathURL to ocidURLsArray's firstObject()
set ocidOppenDirPathURL to ocidSupportDirPathURL's URLByAppendingPathComponent:("Apple/MakePDF")
###フォルダ作っておく
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidOppenDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
###その上で開く
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
set boolDone to appShardWorkspace's openURL:(ocidOppenDirPathURL)


|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ 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 Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes 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 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 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 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 Plist System Events 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 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 SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design 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