Apple サポート App および YouTube チャンネルのお知らせ

*  iOS 向け Apple サポート App のバージョン 5.6 が公開されました。

YouTube - Apple Japan チャンネルで有用なヒントや使い方を配信中です。

コミュニティでの投票について

コミュニティでの投票について解説した記事を公開しました。

Apple Account (Apple ID) の不正利用を確認する方法

Apple Account に関するよくある質問についてはこちらのページを、また不正利用を確認する方法についてはこちらのドキュメントをご参照ください。

しばらく返答が寄せられていないようです。 再度ディスカッションを開始するには、新たに質問してください。

Automator PDF結合時にエラー127がでる

PDF結合時にエラー127がでます。ここ数年は何も問題ありませんでした

* タイトルを変更しました。 Apple Inc.

MacBook Air (2020 or later)

投稿日 2022/04/07 18:23

返信
スレッドに付いたマーク ランキングトップの返信

投稿日 2022/04/21 13:45

情報ありがとうございます。ご紹介のページには「AppleScriptObjC は使えないようでした」とありますが、大丈夫のようですよ。こんな感じで作ってみました。



ショートカットを実行するとダイアログが二回表示されます。最初のダイアログで PDF ファイルを複数選択し、二つ目のダイアログで結合後のファイルの名前と場所を指定。


use AppleScript version "2.8"
use scripting additions
use framework "PDFKit"

property OSX : current application
property nil : missing value

on run
    set uti to "com.adobe.pdf"
    set msg to "PDF ファイルを選択してください。"

    set args to choose file of type uti with prompt msg with multiple selections allowed

    set pdf to OSX's PDFDocument's alloc()'s init()
    set idx to 0

    repeat with f in args
        set furl to (OSX's NSURL's fileURLWithPath:(f's POSIX path))
        set doc to (OSX's PDFDocument's alloc()'s initWithURL:furl)
        repeat with i from 1 to doc's pageCount()
            (pdf's insertPage:(doc's pageAtIndex:(i - 1)) atIndex:idx)
            set idx to idx + 1
        end repeat
    end repeat

    set fpath to choose file name default name "out.pdf" default location (path to desktop)

    if pdf's writeToFile:(fpath's POSIX path) then
        return fpath as text
    else
        error "failed to write to file \"" & fpath & "\""
    end if
end run


動作確認: Parallels Desktop 17 上の Monterey 12.3


返信: 4
スレッドに付いたマーク ランキングトップの返信

2022/04/21 13:45 superr25 への返信

情報ありがとうございます。ご紹介のページには「AppleScriptObjC は使えないようでした」とありますが、大丈夫のようですよ。こんな感じで作ってみました。



ショートカットを実行するとダイアログが二回表示されます。最初のダイアログで PDF ファイルを複数選択し、二つ目のダイアログで結合後のファイルの名前と場所を指定。


use AppleScript version "2.8"
use scripting additions
use framework "PDFKit"

property OSX : current application
property nil : missing value

on run
    set uti to "com.adobe.pdf"
    set msg to "PDF ファイルを選択してください。"

    set args to choose file of type uti with prompt msg with multiple selections allowed

    set pdf to OSX's PDFDocument's alloc()'s init()
    set idx to 0

    repeat with f in args
        set furl to (OSX's NSURL's fileURLWithPath:(f's POSIX path))
        set doc to (OSX's PDFDocument's alloc()'s initWithURL:furl)
        repeat with i from 1 to doc's pageCount()
            (pdf's insertPage:(doc's pageAtIndex:(i - 1)) atIndex:idx)
            set idx to idx + 1
        end repeat
    end repeat

    set fpath to choose file name default name "out.pdf" default location (path to desktop)

    if pdf's writeToFile:(fpath's POSIX path) then
        return fpath as text
    else
        error "failed to write to file \"" & fpath & "\""
    end if
end run


動作確認: Parallels Desktop 17 上の Monterey 12.3


Automator PDF結合時にエラー127がでる

Apple サポートコミュニティへようこそ
Apple ユーザ同士でお使いの製品について助け合うフォーラムです。Apple Account を使ってご参加ください。