ラベル PDF の投稿を表示しています。 すべての投稿を表示
ラベル PDF の投稿を表示しています。 すべての投稿を表示

20260325

【cpdf】PDFページに透かしを入れる


【cpdf】PDFページに透かしを入れる

ダウンロードはこちらから
NOTE記事一覧ですnote.com

20260324

【macOS】PDFの暗号化とパスワード設定(Acrobat不要)


【macOS】PDFの暗号化とパスワード設定(Acrobat不要)

NOTE記事一覧ですnote.com

20260323

【cpdf】PDFページの分割(右から左への2分割 RTL)


【cpdf】PDFページの分割(右から左への2分割 RTL)

NOTE記事一覧ですnote.com

【cpdf】PDFページの分割(左から右への2分割LTR)


【cpdf】PDFページの分割(左から右への2分割LTR)

NOTE記事一覧ですnote.com

【cpdf】PDFページの分割(上から下への2分割TTB)


【cpdf】PDFページの分割(上から下への2分割TTB)

NOTE記事一覧ですnote.com

20260320

【cpdf】PDFページの原寸集4UP(PrintPos4_4in1)


【cpdf】PDFページの原寸集42UP

ソースのダウンロードはこちら

【cpdf】PDFページの原寸集4UP(PrintPos3_4in1)


【cpdf】PDFページの原寸集42UP

ソースのダウンロードはこちら

【cpdf】PDFページの原寸集4UP(PrintPos2_4in1)


【cpdf】PDFページの原寸集42UP

ソースのダウンロードはこちら

【cpdf】PDFページの原寸集4UP(PrintPos1_4in1)


【cpdf】PDFページの原寸集42UP

ソースのダウンロードはこちら

【cpdf】PDFページの原寸集約2UP(2in1_4原稿横_B2T)


【cpdf】PDFページの原寸集約2UP

ソースのダウンロードはこちら

【cpdf】PDFページの原寸集約2UP(2in1_3原稿横_T2B)


【cpdf】PDFページの原寸集約2UP

ソースのダウンロードはこちら

【cpdf】PDFページの原寸集約2UP(2in1_2原稿縦_L2R)


【cpdf】PDFページの原寸集約2UP

ソースのダウンロードはこちら

【cpdf】PDFページの原寸集約2UP(2in1_1原稿縦_R2L)


【cpdf】PDFページの原寸集約2UP

ソースのダウンロードはこちら

20260319

【cpdf】PDFドキュメント 各PDFページに埋め込まれているフォント情報を一覧出力する


【CPDF】PDFドキュメント 各PDFページに埋め込まれているフォント情報を一覧出力する


ソースのダウンロードはこちら

20260318

[cpdf 2.9] PDFの各ページの回転を現在の天地向きで回転0になるように設定する


[cpdf 2.9] PDFの各ページの回転を現在の天地向きで回転0になるように設定する

https://www.coherentpdf.com

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

現在の回転を天地とする.scpt
ソース
001#!/usr/bin/env osascript
002#coding: utf-8
003----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
004(*
005cpdfが別途必要です
006<https://github.com/coherentgraphics/cpdf-binaries>
007オプション
008Chapter 3
009Pages
010https://www.coherentpdf.com/cpdfmanual/cpdfmanualch3.html
011PDFの各ページが回転していても
012現在の表示を回転0として天地向きとします
013cpdfインストーラー同封版
014cpdfが未インストールの場合インストールします
015困る場合は実行しないでください
016cpdfインストール先は
017/Users/ユーザーID/Library/Application Support/bin/cpdf
018v1 初回作成
019v1.1 インストール機能をつけた
020com.cocolog-nifty.quicktimer.icefloe *)
021----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
022use AppleScript version "2.8"
023use framework "Foundation"
024use framework "UniformTypeIdentifiers"
025use framework "AppKit"
026use scripting additions
027property refMe : a reference to current application
028##################
029#cpdfバイナリーのパス
030set strBinPath to ("~/Library/Application Support/bin/cpdf/cpdf") as text
031set ocidBinPathStr to refMe's NSString's stringWithString:(strBinPath)
032set ocidBinPath to ocidBinPathStr's stringByStandardizingPath()
033set ocidBinFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidBinPath) isDirectory:(false)
034##################
035#インストールチェック
036set appFileManager to refMe's NSFileManager's defaultManager()
037set boolExist to appFileManager's fileExistsAtPath:(ocidBinPath) isDirectory:(false)
038if boolExist is false then
039   set boolDone to doInstall()
040   if boolDone is false then
041      log "インストールに失敗しました"
042      return false
043   end if
044end if
045##################
046#入力ファイル
047set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
048set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
049set aliasDesktopDirPath to (ocidDesktopDirPathURL's absoluteURL()) as alias
050set listUTI to {"com.adobe.pdf"} as list
051set strMes to ("PDFファイルを選んでください") as text
052set strPrompt to ("" & return & "PDFファイルを選んでください" & return & "現在のPDFページ回転で天地向きにセットします" & return & "") as text
053try
054   tell application "SystemUIServer"
055      activate
056      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
057   end tell
058on error
059   log "エラーしました"
060   return "エラーしました"
061end try
062##################
063#入力ファイルパス
064set strFilePath to (POSIX path of aliasFilePath) as text
065set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
066set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
067set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
068##################
069#出力ファイル
070set ocidFileName to ocidFilePathURL's lastPathComponent()
071set strBaseFileName to (ocidFileName's stringByDeletingPathExtension()) as text
072set strExtensionName to (ocidFilePathURL's pathExtension()) as text
073set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
074set aliasContainerDirPath to (ocidContainerDirPathURL's absoluteURL()) as alias
075#
076set strDefaultFileName to (strBaseFileName & "-編集済.pdf") as text
077#
078set strPromptText to ("名前を決めてください") as text
079set strMesText to ("" & return & "名前を決めてください" & return & "天地向き修正後のPDFの名前") as text
080###ファイル名 ダイアログ
081tell application "SystemUIServer"
082   activate
083   set aliasFilePath to (choose file name strMesText default location aliasContainerDirPath default name strDefaultFileName with prompt strPromptText) as «class furl»
084end tell
085##################
086#出力パス
087set strSaveFilePath to (POSIX path of aliasFilePath) as text
088set ocidSaveFilePathStr to refMe's NSString's stringWithString:(strSaveFilePath)
089set ocidSaveFilePath to ocidSaveFilePathStr's stringByStandardizingPath()
090set ocidSaveFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveFilePath) isDirectory:false)
091set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
092###拡張子
093set strExtension to (ocidFilePathURL's pathExtension()) as text
094###最後のアイテムがファイル名
095set strFileName to (ocidFilePathURL's lastPathComponent()) as text
096###拡張子のつけ忘れ対策
097if strFileName does not contain strExtensionName then
098   set strFileName to (strFileName & "." & strExtensionName) as text
099   set ocidFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strFileName)
100end if
101##################
102#コマンド整形
103set strSaveFilePath to (ocidSaveFilePathURL's |path|()) as text
104set strFilePath to (ocidFilePathURL's |path|()) as text
105set strBinPath to (ocidBinFilePathURL's |path|()) as text
106#
107set strCmd to ("'" & strBinPath & "' -upright '" & strFilePath & "' -o '" & strSaveFilePath & "'") as text
108log strCmd
109do shell script strCmd
110
111##################
112#開く
113set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
114set ocidOpenURLsArray to refMe's NSMutableArray's alloc()'s init()
115(ocidOpenURLsArray's addObject:(ocidSaveFilePathURL))
116appSharedWorkspace's activateFileViewerSelectingURLs:(ocidOpenURLsArray)
117tell application "Finder" to activate
118return true
119##############################
120#インストールサプ
121to doInstall()
122   ##############################
123   #設定項目
124   #ダウンロードURL
125   set strURL to ("https://codeload.github.com/coherentgraphics/cpdf-binaries/zip/refs/heads/master") as text
126   #インストール先
127   set strSaveDir to ("~/Library/Application Support/bin/cpdf") as text
128   ##############################
129   #メタ文字
130   set strLF to ("" & linefeed & "") as text
131   set strCR to ("" & return & "") as text
132   set strCRLF to ("" & return & linefeed & "") as text
133   set strSpace to ("" & space & "") as text
134   set strTab to ("" & tab & "") as text
135   ##############################
136   #ダウンロード先(起動時に削除される項目)
137   set appFileManager to refMe's NSFileManager's defaultManager()
138   set ocidTempDirURL to appFileManager's temporaryDirectory()
139   set ocidUUID to refMe's NSUUID's alloc()'s init()
140   set ocidUUIDString to ocidUUID's UUIDString
141   set ocidDownloadDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:true
142   set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
143   ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
144   set listDone to appFileManager's createDirectoryAtURL:(ocidDownloadDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
145   set ocidDownloadFilePathURL to ocidDownloadDirPathURL's URLByAppendingPathComponent:("master.zip") isDirectory:(false)
146   set strDownloadFilePath to (ocidDownloadFilePathURL's |path|()) as text
147   set strExpandDirPath to (ocidDownloadDirPathURL's |path|()) as text
148   ##############################
149   #保存先 最終的なインストール先
150   set ocidSaveDirPathStr to refMe's NSString's stringWithString:(strSaveDir)
151   set ocidSaveDirPath to ocidSaveDirPathStr's stringByStandardizingPath()
152   set ocidSaveDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveDirPath) isDirectory:false)
153   
154   ##############################
155   #今あるものをゴミ箱へ
156   set boolDirExists to appFileManager's fileExistsAtPath:(ocidSaveDirPath) isDirectory:(true)
157   if (boolDirExists as boolean) is true then
158      set appFileManager to refMe's NSFileManager's defaultManager()
159      set listDone to (appFileManager's trashItemAtURL:(ocidSaveDirPathURL) resultingItemURL:(ocidDownloadDirPathURL) |error|:(reference))
160   end if
161   
162   ##############################
163   #新たにフォルダを作り直す
164   ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
165   set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
166   ##############################
167   #リダイレクト先
168   set strCmd to ("/usr/bin/curl -s -L -I -o /dev/null -w '%{url_effective}' \"" & strURL & "\"") as text
169   try
170      set strRedirectURL to (do shell script strCmd) as text
171   on error strErrMsg number numErrNo
172      log "No: " & numErrNo & linefeed & "Error:" & strErrMsg
173      return false
174   end try
175   ##############################
176   #ダウンロード
177   set strCmd to ("/usr/bin/curl -L -o \"" & strDownloadFilePath & "\" \"" & strRedirectURL & "\" --connect-timeout 20") as text
178   try
179      set strResponse to (do shell script strCmd) as text
180   on error strErrMsg number numErrNo
181      log "No: " & numErrNo & linefeed & "Error:" & strErrMsg
182      return false
183   end try
184   ##############################
185   #解凍
186   set strCmd to ("/usr/bin/bsdtar -xzf \"" & strDownloadFilePath & "\" -C \"" & strExpandDirPath & "\"") as text
187   try
188      set strResponse to (do shell script strCmd) as text
189   on error strErrMsg number numErrNo
190      log "No: " & numErrNo & linefeed & "Error:" & strErrMsg
191      return false
192   end try
193   ##############################
194   #解凍結果
195   set reocdSystemInfot to (system info) as record
196   set strCPU to (CPU type of reocdSystemInfot) as text
197   #CPUで分岐
198   if strCPU contains "ARM" then
199      #ARM
200      set ocidExpandBinFilePathURL to ocidDownloadDirPathURL's URLByAppendingPathComponent:("cpdf-binaries-master/OSX-ARM/cpdf") isDirectory:(false)
201      
202   else
203      #INTEL
204      set ocidExpandBinFilePathURL to ocidDownloadDirPathURL's URLByAppendingPathComponent:("cpdf-binaries-master/OSX-Intel/cpdf") isDirectory:(false)
205      
206   end if
207   
208   #最終的なバイナリーの移動先
209   set ocidDistBinFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("cpdf") isDirectory:(false)
210   #移動
211   set listDone to (appFileManager's moveItemAtURL:(ocidExpandBinFilePathURL) toURL:(ocidDistBinFilePathURL) |error|:(reference))
212   ##############################
213   #解凍前のファイルをゴミ箱へ
214   set appFileManager to refMe's NSFileManager's defaultManager()
215   set listDone to (appFileManager's trashItemAtURL:(ocidDownloadDirPathURL) resultingItemURL:(ocidDownloadDirPathURL) |error|:(reference))
216   
217   return true
218   
219end doInstall
AppleScriptで生成しました