AppleScript PDF

Quartz PDFContext AppendModeについてのメモ

Gz65uwxb0ait6kl

Quartz PDFContext AppendMode
MacOSのプレビューアプリや
/usr/sbin/cupsfilterで生成されたPDFに関連してくる



PDFは基本的には

PDFドキュメントの中にPDFページが格納されていて
PDFページには『注釈』が格納されている

フォントや画像といった要素は
WEBに最適化だとページ毎に
それいがいはPDFドキュメント自体に格納される



AppendMode

元々あるPDFドキュメントにPDFページや注釈といったリソースを追加する場合
元々あるPDFドキュメントとPDFページは変更せずに
追加される要素をドキュメントにAppend追加する
そのため、アプリケーションや各種ライブラリが
PDFページに必要な要素を収集できない『場合がある』ため
AppendModeに対応していないソフトウェアやライブラリを利用すると
エラーに『なりやすい』ことになる



解決方法
macOSの場合はプレビューアプリで
最適化保存を行うことで『たいていのPDFは』問題を回避できる『事が多い』

20241017025232_1170x414

|

[PDF]見開き2in1ページを左右に分割 まとめ

1:Acrobatを使う(Windowsも可)
2:PDFKitを使う(macOS専用)
3:Pythonを使う
4:コマンドラインツールを使う



1:Acrobatを使う(Windowsも可)
[Acrobat]左右見開きページを個別ページに分割する(javascript Windowsでも実行可能)
https://quicktimer.cocolog-nifty.com/icefloe/2024/09/post-dff160.html


2:PDFKitを使う(macOS専用)
PDF2in1になっている見開きPDFを左右にページを分割する
https://quicktimer.cocolog-nifty.com/icefloe/2024/09/post-a14d0c.html


3:Pythonを使う
[fitz]見開きPDFを左右分割
https://quicktimer.cocolog-nifty.com/icefloe/2024/09/post-7014ef.html


4:コマンドラインツールを使う
[cpdf]見開き2in1ページを左右に分割
https://quicktimer.cocolog-nifty.com/icefloe/2024/09/post-4873e4.html

|

[cpdf]見開き2in1ページを左右に分割




ダウンロード - cpdfv2.zip




2in1右→左分割.applescript
AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#cpdfが別途必要です
004#<https://github.com/coherentgraphics/cpdf-binaries>
005# com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "UniformTypeIdentifiers"
010use framework "AppKit"
011use scripting additions
012property refMe : a reference to current application
013
014
015##################
016#バイナリーのパス
017#cpdfバイナリーのパス
018set strBinPath to "~/bin/cpdf/cpdf" as text
019set ocidBinPathStr to refMe's NSString's stringWithString:(strBinPath)
020set ocidBinPath to ocidBinPathStr's stringByStandardizingPath()
021set ocidBinFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidBinPath) isDirectory:(false)
022
023##################
024#入力ファイル
025set appFileManager to refMe's NSFileManager's defaultManager()
026set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
027set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
028set aliasDesktopDirPath to (ocidDesktopDirPathURL's absoluteURL()) as alias
029#ダイアログを全面に
030set strName to (name of current application) as text
031if strName is "osascript" then
032  tell application "Finder" to activate
033else
034  tell current application to activate
035end if
036set listUTI to {"com.adobe.pdf"}
037set strMes to ("ファイルを選んでください") as text
038set strPrompt to ("ファイルを選んでください") as text
039try
040  ### ファイル選択時
041  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDesktopDirPath) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
042on error
043  log "エラーしました"
044  return "エラーしました"
045end try
046##################
047#入力ファイルパス
048set strFilePath to (POSIX path of aliasFilePath) as text
049set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
050set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
051set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
052##################
053#出力ファイル
054set ocidFileName to ocidFilePathURL's lastPathComponent()
055set strBaseFileName to (ocidFileName's stringByDeletingPathExtension()) as text
056set strDefaultFileName to (strBaseFileName & ".左右分割済.pdf") as text
057set strExtensionName to (ocidFilePathURL's pathExtension()) as text
058set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
059set aliasContainerDirPath to (ocidContainerDirPathURL's absoluteURL()) as alias
060
061set strPromptText to "名前を決めてください" as text
062set strMesText to "名前を決めてください" as text
063###ファイル名 ダイアログ
064set aliasFilePath to (choose file name strMesText default location aliasContainerDirPath default name strDefaultFileName with prompt strPromptText) as «class furl»
065##################
066#出力パス
067set strSaveFilePath to (POSIX path of aliasFilePath) as text
068set ocidSaveFilePathStr to refMe's NSString's stringWithString:(strSaveFilePath)
069set ocidSaveFilePath to ocidSaveFilePathStr's stringByStandardizingPath()
070set ocidSaveFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveFilePath) isDirectory:false)
071set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
072###拡張子
073set strExtension to (ocidFilePathURL's pathExtension()) as text
074###最後のアイテムがファイル名
075set strFileName to (ocidFilePathURL's lastPathComponent()) as text
076###拡張子のつけ忘れ対策
077if strFileName does not contain strExtensionName then
078  set strFileName to (strFileName & "." & strExtensionName) as text
079  set ocidFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strFileName)
080end if
081##################
082#コマンド整形
083set strSaveFilePath to (ocidSaveFilePathURL's |path|()) as text
084set strFilePath to (ocidFilePathURL's |path|()) as text
085set strBinPath to (ocidBinFilePathURL's |path|()) as text
086#1ページ目のページの回転を取得
087set strCommandText to ("\"" & strBinPath & "\" -page-info -json -utf8   \"" & strFilePath & "\" 1 ") as text
088log strCommandText
089try
090  set strJsonResponse to (do shell script strCommandText) as text
091on error
092  return "コマンドでエラーになりました"
093end try
094#戻り値のJSONから1ページ目の回転値を取得
095set ocidJsonStr to refMe's NSString's stringWithString:(strJsonResponse)
096set ocidStringData to ocidJsonStr's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
097set ocidOption to (refMe's NSJSONReadingMutableContainers)
098set listJSONSerialization to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidStringData) options:(ocidOption) |error| :(reference))
099set ocidPlistDict to (item 1 of listJSONSerialization)'s firstObject()
100set numPageRotation to (ocidPlistDict's valueForKey:("Rotation")) as integer
101
102#ページの回転に合わせたコマンド整形
103if numPageRotation = 0 then
104  set strCommandText to ("\"" & strBinPath & "\" -chop \"2 1\" -chop-rtl \"" & strFilePath & "\" -o \"" & strSaveFilePath & "\"") as text
105else if numPageRotation = 90 then
106  set strCommandText to ("\"" & strBinPath & "\" -chop \"1 2\" -chop-columns \"" & strFilePath & "\" -o \"" & strSaveFilePath & "\"") as text
107else if numPageRotation = 270 then
108  set strCommandText to ("\"" & strBinPath & "\" -chop \"1 2\" -chop-btt \"" & strFilePath & "\" -o \"" & strSaveFilePath & "\"") as text
109else if numPageRotation = 180 then
110  set strCommandText to ("\"" & strBinPath & "\" -chop \"2 1\" \"" & strFilePath & "\" -o \"" & strSaveFilePath & "\"") as text
111end if
112log strCommandText
113try
114  do shell script strCommandText
115on error
116  return "コマンドでエラーになりました"
117end try
AppleScriptで生成しました

2in1左→右分割.applescript
AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#cpdfが別途必要です
004#<https://github.com/coherentgraphics/cpdf-binaries>
005# com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "UniformTypeIdentifiers"
010use framework "AppKit"
011use scripting additions
012property refMe : a reference to current application
013
014
015##################
016#バイナリーのパス
017#cpdfバイナリーのパス
018set strBinPath to "~/bin/cpdf/cpdf" as text
019set ocidBinPathStr to refMe's NSString's stringWithString:(strBinPath)
020set ocidBinPath to ocidBinPathStr's stringByStandardizingPath()
021set ocidBinFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidBinPath) isDirectory:(false)
022
023##################
024#入力ファイル
025set appFileManager to refMe's NSFileManager's defaultManager()
026set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
027set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
028set aliasDesktopDirPath to (ocidDesktopDirPathURL's absoluteURL()) as alias
029#ダイアログを全面に
030set strName to (name of current application) as text
031if strName is "osascript" then
032  tell application "Finder" to activate
033else
034  tell current application to activate
035end if
036set listUTI to {"com.adobe.pdf"}
037set strMes to ("ファイルを選んでください") as text
038set strPrompt to ("ファイルを選んでください") as text
039try
040  ### ファイル選択時
041  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDesktopDirPath) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
042on error
043  log "エラーしました"
044  return "エラーしました"
045end try
046##################
047#入力ファイルパス
048set strFilePath to (POSIX path of aliasFilePath) as text
049set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
050set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
051set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
052##################
053#出力ファイル
054set ocidFileName to ocidFilePathURL's lastPathComponent()
055set strBaseFileName to (ocidFileName's stringByDeletingPathExtension()) as text
056set strDefaultFileName to (strBaseFileName & ".左右分割済.pdf") as text
057set strExtensionName to (ocidFilePathURL's pathExtension()) as text
058set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
059set aliasContainerDirPath to (ocidContainerDirPathURL's absoluteURL()) as alias
060
061set strPromptText to "名前を決めてください" as text
062set strMesText to "名前を決めてください" as text
063###ファイル名 ダイアログ
064set aliasFilePath to (choose file name strMesText default location aliasContainerDirPath default name strDefaultFileName with prompt strPromptText) as «class furl»
065##################
066#出力パス
067set strSaveFilePath to (POSIX path of aliasFilePath) as text
068set ocidSaveFilePathStr to refMe's NSString's stringWithString:(strSaveFilePath)
069set ocidSaveFilePath to ocidSaveFilePathStr's stringByStandardizingPath()
070set ocidSaveFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveFilePath) isDirectory:false)
071set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
072###拡張子
073set strExtension to (ocidFilePathURL's pathExtension()) as text
074###最後のアイテムがファイル名
075set strFileName to (ocidFilePathURL's lastPathComponent()) as text
076###拡張子のつけ忘れ対策
077if strFileName does not contain strExtensionName then
078  set strFileName to (strFileName & "." & strExtensionName) as text
079  set ocidFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strFileName)
080end if
081##################
082#コマンド整形
083set strSaveFilePath to (ocidSaveFilePathURL's |path|()) as text
084set strFilePath to (ocidFilePathURL's |path|()) as text
085set strBinPath to (ocidBinFilePathURL's |path|()) as text
086#1ページ目のページの回転を取得
087set strCommandText to ("\"" & strBinPath & "\" -page-info -json -utf8   \"" & strFilePath & "\" 1 ") as text
088log strCommandText
089try
090  set strJsonResponse to (do shell script strCommandText) as text
091on error
092  return "コマンドでエラーになりました"
093end try
094#戻り値のJSONから1ページ目の回転値を取得
095set ocidJsonStr to refMe's NSString's stringWithString:(strJsonResponse)
096set ocidStringData to ocidJsonStr's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
097set ocidOption to (refMe's NSJSONReadingMutableContainers)
098set listJSONSerialization to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidStringData) options:(ocidOption) |error| :(reference))
099set ocidPlistDict to (item 1 of listJSONSerialization)'s firstObject()
100set numPageRotation to (ocidPlistDict's valueForKey:("Rotation")) as integer
101
102#ページの回転に合わせたコマンド整形
103if numPageRotation = 0 then
104  set strCommandText to ("\"" & strBinPath & "\" -chop \"2 1\"  \"" & strFilePath & "\" -o \"" & strSaveFilePath & "\"") as text
105else if numPageRotation = 90 then
106  set strCommandText to ("\"" & strBinPath & "\" -chop \"1 2\" -chop-btt \"" & strFilePath & "\" -o \"" & strSaveFilePath & "\"") as text
107else if numPageRotation = 270 then
108  set strCommandText to ("\"" & strBinPath & "\" -chop \"1 2\" \"" & strFilePath & "\" -o \"" & strSaveFilePath & "\"") as text
109else if numPageRotation = 180 then
110  set strCommandText to ("\"" & strBinPath & "\" -chop \"2 1\"  -chop-rtl   \"" & strFilePath & "\" -o \"" & strSaveFilePath & "\"") as text
111end if
112log strCommandText
113try
114  do shell script strCommandText
115on error
116  return "コマンドでエラーになりました"
117end try
AppleScriptで生成しました

|

PDF2in1になっている見開きPDFを左右にページを分割する




ダウンロード - スクリプト.zip


ダウンロード - チェック用PDF.zip




AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# Acrobat不要 細かい設定は移動しないので印刷用
004# ページの回転は考慮している
005#右ページが先 左ページが後
006# com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008##自分環境がos12なので2.8にしているだけです
009use AppleScript version "2.8"
010use framework "Foundation"
011use framework "AppKit"
012use framework "PDFKit"
013use scripting additions
014
015property refMe : a reference to current application
016
017#############################
018###ダイアログを前面に出す
019set strName to (name of current application) as text
020if strName is "osascript" then
021  tell application "Finder" to activate
022else
023  tell current application to activate
024end if
025#
026set appFileManager to refMe's NSFileManager's defaultManager()
027set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
028set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
029set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
030set listUTI to {"com.adobe.pdf"}
031set strMes to ("PDF ファイルを選んでください") as text
032set strPrompt to ("PDFファイルを選んでください") as text
033try
034  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
035on error
036  log "エラーしました"
037  return "エラーしました"
038end try
039set strFilePath to (POSIX path of aliasFilePath) as text
040set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
041set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
042set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
043set ocidFileName to ocidFilePathURL's lastPathComponent()
044set ocidFileExtension to ocidFilePathURL's pathExtension()
045set ocidPrefixName to ocidFileName's stringByDeletingPathExtension
046set ocidContainerDirURL to ocidFilePathURL's URLByDeletingLastPathComponent()
047
048###################################
049###ファイル名
050set strPrefixName to ocidPrefixName as text
051set strFileExtension to ocidFileExtension as text
052set strDefaultName to (strPrefixName & ".見開き分割." & strFileExtension) as text
053set strPromptText to "保存ファイル名前を決めてください"
054set strMesText to "保存ファイル名前を決めてください"
055set aliasDefaultLocation to (ocidContainerDirURL's absoluteURL) as alias
056####実在しない『はず』なのでas «class furl»で
057set aliasSaveFilePath to (choose file name strMesText default location aliasDefaultLocation default name strDefaultName with prompt strPromptText) as «class furl»
058set strSaveFilePath to (POSIX path of aliasSaveFilePath) as text
059set ocidSaveFilePathStr to refMe's NSString's stringWithString:(strSaveFilePath)
060set ocidSaveFilePath to ocidSaveFilePathStr's stringByStandardizingPath()
061set ocidSaveFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveFilePath) isDirectory:false)
062###拡張子取得
063set strFileExtensionName to ocidSaveFilePathURL's pathExtension() as text
064###ダイアログで拡張子を取っちゃった時対策
065if strFileExtensionName is not strFileExtension then
066  set ocidSaveFilePathURL to ocidSaveFilePathURL's URLByAppendingPathExtension:strFileExtension
067end if
068
069
070
071###保存するPDF
072set ocidSavePDFdoc to refMe's PDFDocument's alloc()'s init()
073###元になるPDF
074##NSDATAに読み込む
075set ocidOption to (refMe's NSDataReadingMappedIfSafe)
076set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(ocidOption) |error| :(reference)
077if (item 2 of listResponse) = (missing value) then
078  log "正常処理"
079  set ocidReadData to (item 1 of listResponse)
080else if (item 2 of listResponse) ≠ (missing value) then
081  set strErrorNO to (item 2 of listResponse)'s code() as text
082  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
083  refMe's NSLog("■:" & strErrorNO & strErrorMes)
084  return "エラーしました" & strErrorNO & strErrorMes
085end if
086
087################################
088set ocidActivDoc to refMe's PDFDocument's alloc()'s initWithData:(ocidReadData)
089set numCntPage to ocidActivDoc's pageCount()
090##
091set numSetPageNo to 0 as integer
092
093repeat with itemReadPageNo from 0 to (numCntPage - 1) by 1
094  #ページ取り出し
095  set ocidReadPageR to (ocidActivDoc's pageAtIndex:(itemReadPageNo))
096  set ocidReadPageL to (ocidActivDoc's pageAtIndex:(itemReadPageNo))
097  #保存用のPDFにインサートして
098  (ocidSavePDFdoc's insertPage:(ocidReadPageR) atIndex:(numSetPageNo))
099  set numSetPageNo to (numSetPageNo + 1) as integer
100  (ocidSavePDFdoc's insertPage:(ocidReadPageL) atIndex:(numSetPageNo))
101  set numSetPageNo to (numSetPageNo + 1) as integer
102end repeat
103set boolDone to (ocidSavePDFdoc's writeToURL:(ocidSaveFilePathURL))
104if boolDone is true then
105  log "正常処理"
106else if boolDone is false then
107  return false
108end if
109
110
111################################
112set ocidSavePDFdoc to (missing value)
113##NSDATAに読み込む
114set ocidOption to (refMe's NSDataReadingMappedIfSafe)
115set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidSaveFilePathURL) options:(ocidOption) |error| :(reference)
116if (item 2 of listResponse) = (missing value) then
117  log "正常処理"
118  set ocidSaveData to (item 1 of listResponse)
119else if (item 2 of listResponse) ≠ (missing value) then
120  set strErrorNO to (item 2 of listResponse)'s code() as text
121  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
122  refMe's NSLog("■:" & strErrorNO & strErrorMes)
123  return "エラーしました" & strErrorNO & strErrorMes
124end if
125###
126set ocidSavePDFdoc to refMe's PDFDocument's alloc()'s initWithData:(ocidSaveData)
127set numCntPage to ocidSavePDFdoc's pageCount()
128###
129repeat with itemReadPageNo from 0 to (numCntPage - 1) by 2
130  ##########R
131  #保存用のPDFからPDFページを取り出してサイズセット
132  set ocidSavePageR to (ocidSavePDFdoc's pageAtIndex:(itemReadPageNo))
133  #表示サイズCROPを取得
134  set ocidSaveRectR to (ocidSavePageR's boundsForBox:(refMe's kPDFDisplayBoxCropBox))
135  set numOriginRx to refMe's NSMinX(ocidSaveRectR)
136  set numOriginRy to refMe's NSMinY(ocidSaveRectR)
137  set numPageRw to refMe's NSWidth(ocidSaveRectR)
138  set numPageRh to refMe's NSHeight(ocidSaveRectR)
139  #
140  set numPageRotationR to ocidSavePageR's |rotation|()
141  log numPageRotationR
142  #
143  if numPageRh > numPageRw then
144    if numPageRotationR = 0 then
145      set numSetOriginRy to ((numPageRh / 2)) as number
146      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numSetOriginRy, numPageRw, (numPageRh / 2))
147    else if numPageRotationR = 360 then
148      set numSetOriginRy to ((numPageRh / 2)) as number
149      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numSetOriginRy, numPageRw, (numPageRh / 2))
150    else if numPageRotationR = 90 then
151      set numSetOriginRy to ((numPageRh / 2)) as number
152      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numSetOriginRy, numPageRw, (numPageRh / 2))
153    else if numPageRotationR = 180 then
154      set numSetOriginRy to ((numPageRh / 2)) as number
155      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numSetOriginRy, numPageRw, (numPageRh / 2))
156    else if numPageRotationR = 270 then
157      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numOriginRy, numPageRw, (numPageRh / 2))
158    end if
159  else
160    if numPageRotationR = 0 then
161      set numSetOriginRx to ((numPageRw / 2)) as number
162      set ocidSetRectR to refMe's NSRect's NSMakeRect(numSetOriginRx, numOriginRy, (numPageRw / 2), numPageRh)
163    else if numPageRotationR = 360 then
164      set numSetOriginRx to ((numPageRw / 2)) as number
165      set ocidSetRectR to refMe's NSRect's NSMakeRect(numSetOriginRx, numOriginRy, (numPageRw / 2), numPageRh)
166    else if numPageRotationR = 90 then
167      set numSetOriginRx to ((numPageRw / 2)) as number
168      set ocidSetRectR to refMe's NSRect's NSMakeRect(numSetOriginRx, numOriginRy, (numPageRw / 2), numPageRh)
169    else if numPageRotationR = 180 then
170      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numOriginRy, (numPageRw / 2), numPageRh)
171    else if numPageRotationR = 270 then
172      set numSetOriginRx to ((numPageRw / 2)) as number
173      set ocidSetRectR to refMe's NSRect's NSMakeRect(numSetOriginRx, numOriginRy, (numPageRw / 2), numPageRh)
174    end if
175  end if
176  #
177  (ocidSavePageR's setBounds:(ocidSetRectR) forBox:(refMe's kPDFDisplayBoxCropBox))
178  (ocidSavePageR's setBounds:(ocidSetRectR) forBox:(refMe's kPDFDisplayBoxBleedBox))
179  (ocidSavePageR's setBounds:(ocidSetRectR) forBox:(refMe's kPDFDisplayBoxTrimBox))
180  (ocidSavePageR's setBounds:(ocidSetRectR) forBox:(refMe's kPDFDisplayBoxMediaBox))
181  
182  #########L
183  set ocidSavePageL to (ocidSavePDFdoc's pageAtIndex:(itemReadPageNo + 1))
184  #表示サイズCROPを取得
185  set ocidSaveRectL to (ocidSavePageL's boundsForBox:(refMe's kPDFDisplayBoxCropBox))
186  
187  set numOriginLx to refMe's NSMinX(ocidSaveRectL)
188  set numOriginLy to refMe's NSMinY(ocidSaveRectL)
189  set numPageLw to refMe's NSWidth(ocidSaveRectL)
190  set numPageLh to refMe's NSHeight(ocidSaveRectL)
191  set numPageRotationL to ocidSavePageL's |rotation|()
192  if numPageLh > numPageLw then
193    if numPageRotationR = 0 then
194      set ocidSetRectL to refMe's NSRect's NSMakeRect(numOriginLx, numOriginLy, numPageLw, (numPageLh / 2))
195    else if numPageRotationR = 90 then
196      set ocidSetRectL to refMe's NSRect's NSMakeRect(numOriginLx, numOriginLy, numPageLw, (numPageLh / 2))
197    else if numPageRotationR = 180 then
198      set ocidSetRectL to refMe's NSRect's NSMakeRect(numOriginLx, numOriginLy, numPageLw, (numPageLh / 2))
199    else if numPageRotationR = 270 then
200      set numSetOriginLy to ((numPageLh / 2)) as number
201      set ocidSetRectL to refMe's NSRect's NSMakeRect(numOriginLx, numSetOriginLy, numPageLw, (numPageLh / 2))
202    else if numPageRotationR = 360 then
203      set ocidSetRectL to refMe's NSRect's NSMakeRect(numOriginLx, numOriginLy, numPageLw, (numPageLh / 2))
204    end if
205  else
206    if numPageRotationR = 0 then
207      set ocidSetRectL to refMe's NSRect's NSMakeRect(numOriginLx, numOriginLy, (numPageLw / 2), numPageLh)
208    else if numPageRotationR = 90 then
209      set ocidSetRectL to refMe's NSRect's NSMakeRect(numOriginLx, numOriginLy, (numPageLw / 2), numPageLh)
210    else if numPageRotationR = 180 then
211      set numSetOriginLx to ((numPageLw / 2)) as number
212      set ocidSetRectL to refMe's NSRect's NSMakeRect(numSetOriginLx, numOriginLy, (numPageLw / 2), numPageLh)
213    else if numPageRotationR = 270 then
214      set ocidSetRectL to refMe's NSRect's NSMakeRect(numOriginLx, numOriginLy, (numPageLw / 2), numPageLh)
215    else if numPageRotationR = 360 then
216      set ocidSetRectL to refMe's NSRect's NSMakeRect(numOriginLx, numOriginLy, (numPageLw / 2), numPageLh)
217    end if
218  end if
219  log ocidSetRectL
220  (ocidSavePageL's setBounds:(ocidSetRectL) forBox:(refMe's kPDFDisplayBoxCropBox))
221  (ocidSavePageL's setBounds:(ocidSetRectL) forBox:(refMe's kPDFDisplayBoxBleedBox))
222  (ocidSavePageL's setBounds:(ocidSetRectL) forBox:(refMe's kPDFDisplayBoxTrimBox))
223  (ocidSavePageL's setBounds:(ocidSetRectL) forBox:(refMe's kPDFDisplayBoxMediaBox))
224  
225end repeat
226
227set boolDone to (ocidSavePDFdoc's writeToURL:(ocidSaveFilePathURL))
228if boolDone is true then
229  log "正常処理"
230else if boolDone is false then
231  return false
232end if
AppleScriptで生成しました

AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# Acrobat不要 細かい設定は移動しないので印刷用
004# ページの回転は考慮している
005#左ページが先 右ページが後
006# com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008##自分環境がos12なので2.8にしているだけです
009use AppleScript version "2.8"
010use framework "Foundation"
011use framework "AppKit"
012use framework "PDFKit"
013use scripting additions
014
015property refMe : a reference to current application
016
017#############################
018###ダイアログを前面に出す
019set strName to (name of current application) as text
020if strName is "osascript" then
021  tell application "Finder" to activate
022else
023  tell current application to activate
024end if
025#
026set appFileManager to refMe's NSFileManager's defaultManager()
027set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
028set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
029set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
030set listUTI to {"com.adobe.pdf"}
031set strMes to ("PDF ファイルを選んでください") as text
032set strPrompt to ("PDFファイルを選んでください") as text
033try
034  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
035on error
036  log "エラーしました"
037  return "エラーしました"
038end try
039set strFilePath to (POSIX path of aliasFilePath) as text
040set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
041set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
042set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
043set ocidFileName to ocidFilePathURL's lastPathComponent()
044set ocidFileExtension to ocidFilePathURL's pathExtension()
045set ocidPrefixName to ocidFileName's stringByDeletingPathExtension
046set ocidContainerDirURL to ocidFilePathURL's URLByDeletingLastPathComponent()
047
048###################################
049###ファイル名
050set strPrefixName to ocidPrefixName as text
051set strFileExtension to ocidFileExtension as text
052set strDefaultName to (strPrefixName & ".見開き分割." & strFileExtension) as text
053set strPromptText to "保存ファイル名前を決めてください"
054set strMesText to "保存ファイル名前を決めてください"
055set aliasDefaultLocation to (ocidContainerDirURL's absoluteURL) as alias
056####実在しない『はず』なのでas «class furl»で
057set aliasSaveFilePath to (choose file name strMesText default location aliasDefaultLocation default name strDefaultName with prompt strPromptText) as «class furl»
058set strSaveFilePath to (POSIX path of aliasSaveFilePath) as text
059set ocidSaveFilePathStr to refMe's NSString's stringWithString:(strSaveFilePath)
060set ocidSaveFilePath to ocidSaveFilePathStr's stringByStandardizingPath()
061set ocidSaveFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveFilePath) isDirectory:false)
062###拡張子取得
063set strFileExtensionName to ocidSaveFilePathURL's pathExtension() as text
064###ダイアログで拡張子を取っちゃった時対策
065if strFileExtensionName is not strFileExtension then
066  set ocidSaveFilePathURL to ocidSaveFilePathURL's URLByAppendingPathExtension:strFileExtension
067end if
068
069
070
071###保存するPDF
072set ocidSavePDFdoc to refMe's PDFDocument's alloc()'s init()
073###元になるPDF
074##NSDATAに読み込む
075set ocidOption to (refMe's NSDataReadingMappedIfSafe)
076set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(ocidOption) |error| :(reference)
077if (item 2 of listResponse) = (missing value) then
078  log "正常処理"
079  set ocidReadData to (item 1 of listResponse)
080else if (item 2 of listResponse) ≠ (missing value) then
081  set strErrorNO to (item 2 of listResponse)'s code() as text
082  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
083  refMe's NSLog("■:" & strErrorNO & strErrorMes)
084  return "エラーしました" & strErrorNO & strErrorMes
085end if
086
087################################
088set ocidActivDoc to refMe's PDFDocument's alloc()'s initWithData:(ocidReadData)
089set numCntPage to ocidActivDoc's pageCount()
090##
091set numSetPageNo to 0 as integer
092
093repeat with itemReadPageNo from 0 to (numCntPage - 1) by 1
094  #ページ取り出し
095  set ocidReadPageR to (ocidActivDoc's pageAtIndex:(itemReadPageNo))
096  set ocidReadPageL to (ocidActivDoc's pageAtIndex:(itemReadPageNo))
097  #保存用のPDFにインサートして
098  (ocidSavePDFdoc's insertPage:(ocidReadPageR) atIndex:(numSetPageNo))
099  set numSetPageNo to (numSetPageNo + 1) as integer
100  (ocidSavePDFdoc's insertPage:(ocidReadPageL) atIndex:(numSetPageNo))
101  set numSetPageNo to (numSetPageNo + 1) as integer
102end repeat
103set boolDone to (ocidSavePDFdoc's writeToURL:(ocidSaveFilePathURL))
104if boolDone is true then
105  log "正常処理"
106else if boolDone is false then
107  return false
108end if
109
110
111################################
112set ocidSavePDFdoc to (missing value)
113##NSDATAに読み込む
114set ocidOption to (refMe's NSDataReadingMappedIfSafe)
115set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidSaveFilePathURL) options:(ocidOption) |error| :(reference)
116if (item 2 of listResponse) = (missing value) then
117  log "正常処理"
118  set ocidSaveData to (item 1 of listResponse)
119else if (item 2 of listResponse) ≠ (missing value) then
120  set strErrorNO to (item 2 of listResponse)'s code() as text
121  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
122  refMe's NSLog("■:" & strErrorNO & strErrorMes)
123  return "エラーしました" & strErrorNO & strErrorMes
124end if
125###
126set ocidSavePDFdoc to refMe's PDFDocument's alloc()'s initWithData:(ocidSaveData)
127set numCntPage to ocidSavePDFdoc's pageCount()
128###
129repeat with itemReadPageNo from 0 to (numCntPage - 1) by 2
130  ##########R
131  #保存用のPDFからPDFページを取り出してサイズセット
132  set ocidSavePageR to (ocidSavePDFdoc's pageAtIndex:(itemReadPageNo))
133  #表示サイズCROPを取得
134  set ocidSaveRectR to (ocidSavePageR's boundsForBox:(refMe's kPDFDisplayBoxCropBox))
135  set numOriginRx to refMe's NSMinX(ocidSaveRectR)
136  set numOriginRy to refMe's NSMinY(ocidSaveRectR)
137  set numPageRw to refMe's NSWidth(ocidSaveRectR)
138  set numPageRh to refMe's NSHeight(ocidSaveRectR)
139  #
140  set numPageRotationR to ocidSavePageR's |rotation|()
141  log numPageRotationR
142  if numPageRh > numPageRw then
143    if numPageRotationR = 0 then
144      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numOriginRy, numPageRw, (numPageRh / 2))
145    else if numPageRotationR = 90 then
146      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numOriginRy, numPageRw, (numPageRh / 2))
147    else if numPageRotationR = 180 then
148      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numOriginRy, numPageRw, (numPageRh / 2))
149    else if numPageRotationR = 270 then
150      set numSetOriginRy to ((numPageRh / 2)) as number
151      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numSetOriginRy, numPageRw, (numPageRh / 2))
152    else if numPageRotationR = 360 then
153      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numOriginRy, numPageRw, (numPageRh / 2))
154    end if
155  else
156    if numPageRotationR = 0 then
157      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numOriginRy, (numPageRw / 2), numPageRh)
158    else if numPageRotationR = 90 then
159      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numOriginRy, (numPageRw / 2), numPageRh)
160    else if numPageRotationR = 180 then
161      set numSetOriginRx to ((numPageRw / 2)) as number
162      set ocidSetRectR to refMe's NSRect's NSMakeRect(numSetOriginRx, numOriginRy, (numPageRw / 2), numPageRh)
163    else if numPageRotationR = 270 then
164      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numOriginRy, (numPageRw / 2), numPageRh)
165    else if numPageRotationR = 360 then
166      set ocidSetRectR to refMe's NSRect's NSMakeRect(numOriginRx, numOriginRy, (numPageRw / 2), numPageRh)
167    end if
168  end if
169  
170  
171  
172  
173  #
174  (ocidSavePageR's setBounds:(ocidSetRectR) forBox:(refMe's kPDFDisplayBoxCropBox))
175  (ocidSavePageR's setBounds:(ocidSetRectR) forBox:(refMe's kPDFDisplayBoxBleedBox))
176  (ocidSavePageR's setBounds:(ocidSetRectR) forBox:(refMe's kPDFDisplayBoxTrimBox))
177  (ocidSavePageR's setBounds:(ocidSetRectR) forBox:(refMe's kPDFDisplayBoxMediaBox))
178  
179  #########L
180  set ocidSavePageL to (ocidSavePDFdoc's pageAtIndex:(itemReadPageNo + 1))
181  #表示サイズCROPを取得
182  set ocidSaveRectL to (ocidSavePageL's boundsForBox:(refMe's kPDFDisplayBoxCropBox))
183  
184  set numOriginLx to refMe's NSMinX(ocidSaveRectL)
185  set numOriginLy to refMe's NSMinY(ocidSaveRectL)
186  set numPageLw to refMe's NSWidth(ocidSaveRectL)
187  set numPageLh to refMe's NSHeight(ocidSaveRectL)
188  set numPageRotationL to ocidSavePageL's |rotation|()
189  #
190  if numPageLh > numPageLw then
191    if numPageRotationL = 0 then
192      set numSetOriginLy to ((numPageLh / 2)) as number
193      set ocidSetRectL to refMe's NSLect's NSMakeRect(numOriginLx, numSetOriginLy, numPageLw, (numPageLh / 2))
194    else if numPageRotationL = 360 then
195      set numSetOriginLy to ((numPageLh / 2)) as number
196      set ocidSetRectL to refMe's NSLect's NSMakeRect(numOriginLx, numSetOriginLy, numPageLw, (numPageLh / 2))
197    else if numPageRotationL = 90 then
198      set numSetOriginLy to ((numPageLh / 2)) as number
199      set ocidSetRectL to refMe's NSLect's NSMakeRect(numOriginLx, numSetOriginLy, numPageLw, (numPageLh / 2))
200    else if numPageRotationL = 180 then
201      set numSetOriginLy to ((numPageLh / 2)) as number
202      set ocidSetRectL to refMe's NSLect's NSMakeRect(numOriginLx, numSetOriginLy, numPageLw, (numPageLh / 2))
203    else if numPageRotationL = 270 then
204      set ocidSetRectL to refMe's NSLect's NSMakeRect(numOriginLx, numOriginLy, numPageLw, (numPageLh / 2))
205    end if
206  else
207    if numPageRotationL = 0 then
208      set numSetOriginLx to ((numPageLw / 2)) as number
209      set ocidSetRectL to refMe's NSLect's NSMakeRect(numSetOriginLx, numOriginLy, (numPageLw / 2), numPageLh)
210    else if numPageRotationL = 360 then
211      set numSetOriginLx to ((numPageLw / 2)) as number
212      set ocidSetRectL to refMe's NSLect's NSMakeRect(numSetOriginLx, numOriginLy, (numPageLw / 2), numPageLh)
213    else if numPageRotationL = 90 then
214      set numSetOriginLx to ((numPageLw / 2)) as number
215      set ocidSetRectL to refMe's NSLect's NSMakeRect(numSetOriginLx, numOriginLy, (numPageLw / 2), numPageLh)
216    else if numPageRotationL = 180 then
217      set ocidSetRectL to refMe's NSLect's NSMakeRect(numOriginLx, numOriginLy, (numPageLw / 2), numPageLh)
218    else if numPageRotationL = 270 then
219      set numSetOriginLx to ((numPageLw / 2)) as number
220      set ocidSetRectL to refMe's NSLect's NSMakeRect(numSetOriginLx, numOriginLy, (numPageLw / 2), numPageLh)
221    end if
222  end if
223  log ocidSetRectL
224  (ocidSavePageL's setBounds:(ocidSetRectL) forBox:(refMe's kPDFDisplayBoxCropBox))
225  (ocidSavePageL's setBounds:(ocidSetRectL) forBox:(refMe's kPDFDisplayBoxBleedBox))
226  (ocidSavePageL's setBounds:(ocidSetRectL) forBox:(refMe's kPDFDisplayBoxTrimBox))
227  (ocidSavePageL's setBounds:(ocidSetRectL) forBox:(refMe's kPDFDisplayBoxMediaBox))
228  
229end repeat
230
231set boolDone to (ocidSavePDFdoc's writeToURL:(ocidSaveFilePathURL))
232if boolDone is true then
233  log "正常処理"
234else if boolDone is false then
235  return false
236end if
AppleScriptで生成しました

|

PDFで使用されているフォントをページ毎に調べてテキスト出力する

20240830011522_831x536
[python3]PDFに埋め込まれているフォント名を一覧取得する
https://quicktimer.cocolog-nifty.com/icefloe/2024/05/post-876d77.html

改良版



ダウンロード - pdfembeddedfontnamev2.zip




AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# ファイルをpyファイルに渡すだけの補助スクリプト
005#
006#com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use scripting additions
011
012property refMe : a reference to current application
013
014####スクリプトメニューから実行したら
015tell current application
016  set strName to name as text
017end tell
018if strName is "osascript" then
019  tell application "Finder"
020    activate
021  end tell
022else
023  tell current application
024    activate
025  end tell
026end if
027####UTIリスト PDFのみ
028set listUTI to {"com.adobe.pdf"}
029set aliasDefaultLocation to (path to desktop folder from user domain) as alias
030####ダイアログを出す
031set aliasFilePath to (choose file with prompt "PDFファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
032####PDFのパス
033set strFilePath to POSIX path of aliasFilePath
034set ocidFilePathStr to (refMe's NSString's stringWithString:strFilePath)
035set ocidFilePath to ocidFilePathStr's stringByStandardizingPath
036set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false)
037set strFilePath to (ocidFilePathURL's |path|()) as text
038
039###ディレクトリ 起動時に削除されます
040set appFileManager to refMe's NSFileManager's defaultManager()
041set ocidTempDirURL to appFileManager's temporaryDirectory()
042set ocidUUID to refMe's NSUUID's alloc()'s init()
043set ocidUUIDString to ocidUUID's UUIDString
044set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true)
045#フォルダ生成
046set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
047# アクセス権777
048ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
049set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error| :(reference)
050#パス
051set strFileName to ("doGetFontName.py") as text
052set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:(false)
053set ocidPythonBinPath to (ocidSaveFilePathURL's |path|())
054set strPythonBinPath to (ocidPythonBinPath) as text
055#使用するスクリプト
056set strPyScript to ("#!/usr/bin/env python3\n# coding: utf-8\nimport sys\nimport os\nimport tempfile\nimport uuid\nimport subprocess\nimport fitz\nargGetData = sys.argv\npdf_file_path = str(argGetData[1])\nfile_name = os.path.basename(pdf_file_path)\nlist_fontname = set()\nstr_output_string = \"\"\nstr_output_string += f\"ファイルパス: {pdf_file_path}\\n\"\nstr_output_string += f\"ファイル名: {file_name}\\n\"\nopen_doc = fitz.open(pdf_file_path)\nfor num_page in range(len(open_doc)):\n    str_output_string += \"----------------------\\n\"\n    str_output_string += f\"ページ: {num_page + 1}\\n\"\n    read_page = open_doc.load_page(num_page)\n    list_fonts = read_page.get_fonts()\n    for item_font in list_fonts:\n        str_font_name = item_font[3].split(\"+\")[-1]\n        str_output_string += f\"{str_font_name}\\n\"\n        list_fontname.add(str_font_name)\nsorted_list_fontname = sorted(list_fontname)\nstr_add_fontList = \"\\n\".join(map(str, sorted_list_fontname))\nprint(str_add_fontList)\nstr_save_string = (str_add_fontList + \"\\n----------------------\\n\" + str_output_string)\ntemp_dir = tempfile.gettempdir()\nstr_dir_name = str(uuid.uuid4())\ntemp_dir_path = os.path.join(temp_dir, str_dir_name)\nos.makedirs(temp_dir_path, exist_ok=True)\nstr_save_file_name = file_name + \".txt\"\nsave_file_path = os.path.join(temp_dir_path, str_save_file_name)\nwith open(save_file_path, 'w', encoding='utf-8') as temp_file:\n    temp_file.write(str_save_string)\nsubprocess.run([\"open\", save_file_path])\nsys.exit(0)\n") as text
057set ocidPyScript to refMe's NSString's stringWithString:(strPyScript)
058#保存
059set listDone to ocidPyScript's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
060if (item 1 of listDone) is true then
061  log "保存 正常処理"
062else if (item 2 of listDone) ≠ (missing value) then
063  log (item 2 of listDone)'s code() as text
064  log (item 2 of listDone)'s localizedDescription() as text
065  return "保存 エラーしました"
066end if
067#アクセス権 755
068ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
069set listDone to appFileManager's setAttributes:(ocidAttrDict) ofItemAtPath:(ocidPythonBinPath) |error| :(reference)
070if (item 1 of listDone) is true then
071  log "アクセス権 正常処理"
072else if (item 2 of listDone) ≠ (missing value) then
073  log (item 2 of listDone)'s code() as text
074  log (item 2 of listDone)'s localizedDescription() as text
075  return "アクセス権 エラーしました"
076end if
077################################
078#python3のパスチェック
079try
080  set strCmdText to ("/usr/bin/which python3") as text
081  set strBinPath to (do shell script strCmdText) as text
082on error
083  log "セットアップを実行してください"
084  try
085    do shell script "/usr/bin/xcode-select --install"
086  end try
087  return "python3が見つかりませんでした終了します"
088end try
089
090####添付する場合binディレクトリ内を参照する場合
091(*
092set strBinFileName to ("doGetFontName.py") as text
093tell application "Finder"
094  set aliasPathToMe to (path to me) as alias
095end tell
096#パス
097set strPathToMe to (POSIX path of aliasPathToMe) as text
098set strPathToMeStr to refMe's NSString's stringWithString:(strPathToMe)
099set ocidPathToMe to strPathToMeStr's stringByStandardizingPath()
100set ocidPathToMeURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidPathToMe) isDirectory:false)
101set ocidContainerDirURL to ocidPathToMeURL's URLByDeletingLastPathComponent()
102set ocidBinDirPathURL to ocidContainerDirURL's URLByAppendingPathComponent:("bin") isDirectory:true
103set ocidBinFilePathURL to ocidBinDirPathURL's URLByAppendingPathComponent:(strBinFileName)
104set strPythonBinPath to ocidBinFilePathURL's |path| as text
105*)
106try
107  set strCommandText to ("\"" & strPythonBinPath & "\" \"" & strFilePath & "\"") as text
108  ##  set strCommandText to ("\"" & strPythonBinPath & "\"") as text
109  set strResponse to (do shell script strCommandText) as text
110on error
111  return "コマンドでエラーしました"
112end try
113#戻り値をテキストにして
114set ocidResponse to refMe's NSString's stringWithString:(strResponse)
115#Arrayに
116set ocidFontNameArray to ocidResponse's componentsSeparatedByString:("\t")
117#ソートして
118set ocidSortedArray to ocidFontNameArray's sortedArrayUsingSelector:("localizedStandardCompare:")
119#改行テキストにする
120set ocidOutPutString to ocidSortedArray's componentsJoinedByString:("\n")
121
122##############################
123#####ダイアログ
124##############################
125tell current application
126  set strName to name as text
127end tell
128####スクリプトメニューから実行したら
129if strName is "osascript" then
130  tell application "Finder"
131    activate
132  end tell
133else
134  tell current application
135    activate
136  end tell
137end if
138set strMes to ("埋め込みフォント名です") as text
139set aliasIconPath to (POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ProfileFont.icns") as alias
140try
141  set recordResult to (display dialog strMes with title "戻り値です" default answer (ocidOutPutString as text) buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
142on error
143  return "エラーしました"
144end try
145if (gave up of recordResult) is true then
146  return "時間切れです"
147end if
148##############################
149#####自分自身を再実行
150##############################
151if button returned of recordResult is "再実行" then
152  tell application "Finder"
153    set aliasPathToMe to (path to me) as alias
154  end tell
155  run script aliasPathToMe with parameters "再実行"
156end if
157##############################
158#####値のコピー
159##############################
160if button returned of recordResult is "クリップボードにコピー" then
161  try
162    set strText to text returned of recordResult as text
163    ####ペーストボード宣言
164    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
165    set ocidText to (refMe's NSString's stringWithString:(strText))
166    appPasteboard's clearContents()
167    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
168  on error
169    tell application "Finder"
170      set the clipboard to strText as text
171    end tell
172  end try
173end if
174
175
176return 0
AppleScriptで生成しました

サンプルコード

サンプルソース(参考)
行番号ソース
001#!/usr/bin/env python3
002# coding: utf-8
003import sys
004import os
005import tempfile
006import uuid
007import subprocess
008
009import fitz
010argGetData = sys.argv
011pdf_file_path = str(argGetData[1])
012# テスト用
013# pdf_file_path = "/Library/Documentation/License.lpdf/Contents/Resources/Japanese.lproj/License.pdf"
014# ファイル名を取得
015file_name = os.path.basename(pdf_file_path)
016#出力用のリスト
017list_fontname = set()
018#出力用のテキスト
019str_output_string = ""
020str_output_string += f"ファイルパス: {pdf_file_path}\n"
021str_output_string += f"ファイル名: {file_name}\n"
022
023# PDFを読み込み
024open_doc = fitz.open(pdf_file_path)
025#ページを順番に処理
026for num_page in range(len(open_doc)):
027    #出力テキスト
028    str_output_string += "----------------------\n"
029    str_output_string += f"ページ: {num_page + 1}\n"
030    #PDFページ要素を読み込み
031    read_page = open_doc.load_page(num_page)
032    #フォント要素を読み出し
033    list_fonts = read_page.get_fonts()
034    #読み出したフォント数だけ繰り返す
035    for item_font in list_fonts:
036        #整形して
037        str_font_name = item_font[3].split("+")[-1]
038        #出力用テキストに追加
039        str_output_string += f"{str_font_name}\n"
040        #出力用のリストに追加
041        list_fontname.add(str_font_name)
042#出力用のリストをソートしてページ順に
043sorted_list_fontname = sorted(list_fontname)
044#リスト毎に改行を入れてテキストにする
045str_add_fontList = "\n".join(map(str, sorted_list_fontname))
046#戻り値用のテキスト
047print(str_add_fontList)
048#テキスト化したリストを出力用のテキストに追加
049str_save_string = (str_add_fontList + "\n----------------------\n" + str_output_string)
050#保存先はテンポラリ再起動時に自動削除
051temp_dir = tempfile.gettempdir()
052#UUIDをフォルダ名にしてユニークにしておく
053str_dir_name = str(uuid.uuid4())
054#保存先ディレクトリをパスに
055temp_dir_path = os.path.join(temp_dir, str_dir_name)
056#フォルダ生成
057os.makedirs(temp_dir_path, exist_ok=True)
058#保存ファイル名 ファイル名+テキスト拡張子
059str_save_file_name = file_name + ".txt"
060#保存先テキストのパス
061save_file_path = os.path.join(temp_dir_path, str_save_file_name)
062#保存
063with open(save_file_path, 'w', encoding='utf-8') as temp_file:
064    temp_file.write(str_save_string)
065#デフォルトアプリで開く
066subprocess.run(["open", save_file_path])
067#終了
068sys.exit(0)
AppleScriptで生成しました

|

[Nitro PDF]全ページにページ番号の注釈を入れる(ノンブル的な使い方)


サンプルコード

サンプルソース(参考)
行番号ソース
001
002
003tell application "Nitro PDF Pro"
004  if (count documents) = 0 then
005    return "ドキュメントを開いていません"
006  end if
007  tell front document
008    set numCntPage to (count of pages) as integer
009    repeat with itemNo from 1 to numCntPage
010      tell page itemNo
011        make new text imprint at end of imprints with properties {rich text:itemNo as rich text, x position:36, y position:36, height:16, width:30}
012      end tell
013    end repeat
014  end tell
015end tell
AppleScriptで生成しました

|

[Nitro PDF]全ページの注釈を全部削除




https://downloads.gonitro.com/macos/Nitro%20PDF%20Pro_14.3.dmg



サンプルコード

サンプルソース(参考)
行番号ソース
001
002
003tell application "Nitro PDF Pro"
004  if (count documents) = 0 then
005    return "ドキュメントを開いていません"
006  end if
007  tell front document
008    set numCntPage to (count of pages) as integer
009    repeat with itemNo from 1 to numCntPage
010      tell page itemNo
011        delete imprints
012      end tell
013    end repeat
014  end tell
015  
016end tell
AppleScriptで生成しました

|

[python]画像データを非圧縮でPDF化する


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# 要Xcode
005# python3でPDFを生成する
006#  com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use scripting additions
011
012property refMe : a reference to current application
013################################
014#設定項目 trueでモジュールインストール
015set boolChkModule to false as boolean
016
017
018################################
019#ダイアログ 入力ファイル
020set strName to (name of current application) as text
021if strName is "osascript" then
022  tell application "Finder" to activate
023else
024  tell current application to activate
025end if
026set appFileManager to refMe's NSFileManager's defaultManager()
027set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
028set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
029set aliasDesktopDirPath to (ocidDesktopDirPathURL's absoluteURL()) as alias
030set listUTI to {"public.image"}
031set strMes to ("ファイルを選んでください") as text
032set strPrompt to ("ファイルを選んでください") as text
033try
034  ### ファイル選択時
035  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDesktopDirPath) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
036on error
037  log "エラーしました"
038  return "エラーしました"
039end try
040################################
041#入力パス
042set strFilePath to (POSIX path of aliasFilePath) as text
043set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
044set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
045set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
046#
047set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
048set aliasContainerDirPath to (ocidContainerDirPathURL's absoluteURL()) as alias
049
050################################
051#出力パス
052set strTargetExtension to ("pdf") as text
053set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
054set strBaseFileName to (ocidBaseFilePathURL's lastPathComponent()) as text
055set strDefaultFileName to (strBaseFileName & "." & strTargetExtension) as text
056
057#出力ファイル ダイアログ
058set strName to (name of current application) as text
059if strName is "osascript" then
060  tell application "Finder" to activate
061else
062  tell current application to activate
063end if
064
065set strPromptText to "名前を決めてください" as text
066set strMesText to "名前を決めてください" as text
067#ファイル名 ダイアログ
068set aliasSaveFilePath to (choose file name strMesText default location aliasContainerDirPath default name strDefaultFileName with prompt strPromptText) as «class furl»
069
070################################
071#出力ファイルパス
072set strSaveFilePath to (POSIX path of aliasSaveFilePath) as text
073set ocidSaveFilePathStr to refMe's NSString's stringWithString:(strSaveFilePath)
074set ocidSaveFilePath to ocidSaveFilePathStr's stringByStandardizingPath()
075set ocidSaveFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveFilePath) isDirectory:false)
076#拡張子
077set strSaveExtension to (ocidSaveFilePathURL's pathExtension()) as text
078#最後のアイテムがファイル名
079set strSaveFileName to (ocidSaveFilePathURL's lastPathComponent()) as text
080#拡張子のつけ忘れ対策
081if strSaveFileName does not contain strTargetExtension then
082  set strSaveFileName to (strSaveFileName & "." & strTargetExtension) as text
083  set ocidSaveFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strSaveFileName)
084end if
085
086###################################
087#python3のパスチェック
088try
089  set strCommandText to ("/usr/bin/which python3") as text
090  log strCommandText
091  set strBinPath to (do shell script strCommandText) as text
092on error
093  return "python3が見つかりませんでした終了します"
094end try
095
096
097###################################
098#Pillowパッケージインストールチェック
099if boolChkModule is true then
100  try
101    set strCommandText to ("\"" & strBinPath & "\" -m pip show Pillow") as text
102    log strCommandText
103    set strResponst to (do shell script strCommandText) as text
104  on error
105    set strResponst to "WARNING" as text
106  end try
107  #
108  if strResponst contains "WARNING" then
109    set strCommandText to ("\"" & strBinPath & "\" -m pip install --user Pillow") as text
110    log strCommandText
111    do shell script strCommandText
112  else
113    set strCommandText to ("\"" & strBinPath & "\" -m pip install --upgrade --user Pillow") as text
114    log strCommandText
115    do shell script strCommandText
116  end if
117end if
118
119###################################
120#python3
121#入出力ファイルパス
122set strFilePath to (ocidFilePathURL's |path|()) as text
123set strSaveFilePath to (ocidSaveFilePathURL's |path|()) as text
124#
125set strCommandText to ("\"" & strBinPath & "\" -c \"from PIL import Image; Image.open('" & strFilePath & "').save('" & strSaveFilePath & "', save_all=True)\"") as text
126log strCommandText
127try
128  do shell script strCommandText
129on error
130  return "コマンドでエラーしました"
131end try
132
133
134return
135
AppleScriptで生成しました

|

cpdf

cpdf
https://github.com/coherentgraphics/cpdf-binaries

PDFの各種編集等が可能なコマンドラインツール
便利に使える
2in1等のページ操作が超簡単

ダウンロード - cpdf.zip

|

[python3]PDFに埋め込まれているフォント名を一覧取得する

ダウンロード - pdfembeddedfontname.zip


試す場合は↑こちらをダウンロードしてセットアップしてから利用してください


あくまでも参考にしてください

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

サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# ファイルをpyファイルに渡すだけの補助スクリプト
005#
006#com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use scripting additions
011
012property refMe : a reference to current application
013
014####スクリプトメニューから実行したら
015tell current application
016  set strName to name as text
017end tell
018if strName is "osascript" then
019  tell application "Finder"
020    activate
021  end tell
022else
023  tell current application
024    activate
025  end tell
026end if
027####UTIリスト PDFのみ
028set listUTI to {"com.adobe.pdf"}
029set aliasDefaultLocation to (path to desktop folder from user domain) as alias
030####ダイアログを出す
031set aliasFilePath to (choose file with prompt "PDFファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
032####PDFのパス
033set strFilePath to POSIX path of aliasFilePath
034set ocidFilePathStr to (refMe's NSString's stringWithString:strFilePath)
035set ocidFilePath to ocidFilePathStr's stringByStandardizingPath
036set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false)
037set strFilePath to (ocidFilePathURL's |path|()) as text
038
039###ディレクトリ 起動時に削除されます
040set appFileManager to refMe's NSFileManager's defaultManager()
041set ocidTempDirURL to appFileManager's temporaryDirectory()
042set ocidUUID to refMe's NSUUID's alloc()'s init()
043set ocidUUIDString to ocidUUID's UUIDString
044set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true)
045#フォルダ生成
046set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
047# アクセス権777
048ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
049set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error| :(reference)
050#パス
051set strFileName to ("doGetFontName.py") as text
052set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:(false)
053set ocidPythonBinPath to (ocidSaveFilePathURL's |path|())
054set strPythonBinPath to (ocidPythonBinPath) as text
055#使用するスクリプト
056set strPyScript to ("#! /usr/bin/env python3\n# coding: utf-8\nimport sys\nimport fitz\nargGetData = sys.argv\npdf_file_path = str(argGetData[1])\nlist_fontname = set()\ndoc = fitz.open(pdf_file_path)\nfor page_num in range(len(doc)):\n    num_page = doc.load_page(page_num)\n    list_fonts = num_page.get_fonts()\n    for item_font in list_fonts:\n        str_font_name = item_font[3].split(\"+\")[-1]\n        list_fontname.add(str_font_name)\nprint(\"\t\".join(map(str, list_fontname)))\nsys.exit(0)\n") as text
057set ocidPyScript to refMe's NSString's stringWithString:(strPyScript)
058#保存
059set listDone to ocidPyScript's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
060if (item 1 of listDone) is true then
061  log "保存 正常処理"
062else if (item 2 of listDone) ≠ (missing value) then
063  log (item 2 of listDone)'s code() as text
064  log (item 2 of listDone)'s localizedDescription() as text
065  return "保存 エラーしました"
066end if
067#アクセス権 755
068ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
069set listDone to appFileManager's setAttributes:(ocidAttrDict) ofItemAtPath:(ocidPythonBinPath) |error| :(reference)
070if (item 1 of listDone) is true then
071  log "アクセス権 正常処理"
072else if (item 2 of listDone) ≠ (missing value) then
073  log (item 2 of listDone)'s code() as text
074  log (item 2 of listDone)'s localizedDescription() as text
075  return "アクセス権 エラーしました"
076end if
077################################
078#python3のパスチェック
079try
080  set strCmdText to ("/usr/bin/which python3") as text
081  set strBinPath to (do shell script strCmdText) as text
082on error
083log "セットアップを実行してください"
084try
085  do shell script "/usr/bin/xcode-select --install"
086end try
087  return "python3が見つかりませんでした終了します"
088end try
089
090####添付する場合binディレクトリ内を参照する場合
091(*
092tell application "Finder"
093  set aliasPathToMe to (path to me) as alias
094end tell
095#パス
096set strPathToMe to (POSIX path of aliasPathToMe) as text
097set strPathToMeStr to refMe's NSString's stringWithString:(strPathToMe)
098set ocidPathToMe to strPathToMeStr's stringByStandardizingPath()
099set ocidPathToMeURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidPathToMe) isDirectory:false)
100set ocidContainerDirURL to ocidPathToMeURL's URLByDeletingLastPathComponent()
101set ocidBinDirPathURL to ocidContainerDirURL's URLByAppendingPathComponent:("bin") isDirectory:true
102set ocidBinFilePathURL to ocidBinDirPathURL's URLByAppendingPathComponent:(strBinFileName)
103set strPythonBinPath to ocidBinFilePathURL's |path| as text
104*)
105try
106  set strCommandText to ("\"" & strPythonBinPath & "\" \"" & strFilePath & "\"") as text
107  ##  set strCommandText to ("\"" & strPythonBinPath & "\"") as text
108  set strResponse to (do shell script strCommandText) as text
109on error
110  return "コマンドでエラーしました"
111end try
112#戻り値をテキストにして
113set ocidResponse to refMe's NSString's stringWithString:(strResponse)
114#Arrayに
115set ocidFontNameArray to ocidResponse's componentsSeparatedByString:("\t")
116#ソートして
117set ocidSortedArray to ocidFontNameArray's sortedArrayUsingSelector:("localizedStandardCompare:")
118#改行テキストにする
119set ocidOutPutString to ocidSortedArray's componentsJoinedByString:("\n")
120
121##############################
122#####ダイアログ
123##############################
124tell current application
125  set strName to name as text
126end tell
127####スクリプトメニューから実行したら
128if strName is "osascript" then
129  tell application "Finder"
130    activate
131  end tell
132else
133  tell current application
134    activate
135  end tell
136end if
137set strMes to ("埋め込みフォント名です") as text
138set aliasIconPath to (POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ProfileFont.icns") as alias
139try
140  set recordResult to (display dialog strMes with title "戻り値です" default answer (ocidOutPutString as text) buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
141on error
142  return "エラーしました"
143end try
144if (gave up of recordResult) is true then
145  return "時間切れです"
146end if
147##############################
148#####自分自身を再実行
149##############################
150if button returned of recordResult is "再実行" then
151  tell application "Finder"
152    set aliasPathToMe to (path to me) as alias
153  end tell
154  run script aliasPathToMe with parameters "再実行"
155end if
156##############################
157#####値のコピー
158##############################
159if button returned of recordResult is "クリップボードにコピー" then
160  try
161    set strText to text returned of recordResult as text
162    ####ペーストボード宣言
163    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
164    set ocidText to (refMe's NSString's stringWithString:(strText))
165    appPasteboard's clearContents()
166    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
167  on error
168    tell application "Finder"
169      set the clipboard to strText as text
170    end tell
171  end try
172end if
173
174
175return 0
AppleScriptで生成しました

|

より以前の記事一覧

その他のカテゴリー

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