Skip to main content
Participant
August 17, 2026
Question

aiファイルをAutomatorでPDFに変換し出力したいです

  • August 17, 2026
  • 4 replies
  • 40 views

知識不足のため、お力を貸していただけばと思います。

 

私の環境では2つの出力方法があり、

一つは複合機のサーバーを介した事務所内での通常出力、

もう一つはHotFolderを使用した外部からの出力です(出力する複合機は同一)。

 

Adobeのaiファイルでの出力で運用しているですが

HotFolderではaiファイルが動作保証外のため外部(HotFolder)からの出力する場合に

下記のようなショートカットの設定は可能でしょうか。

 

HotFolderにaiファイルをドラック&ドロップ

AutomatorでaiファイルをPDF(X4が望ましい)に変換

複合機から自動で出力

 

 

MacOS15.7.9です。

よろしくお願いいたします。

    4 replies

    Ten A
    Community Expert
    Community Expert
    August 18, 2026

    AutomatorはIllustrator操作する場合スクリプトで操作する必要があるんですけど、それならスクリプトエディターでドロップレット作ってIllustrator形式ファイルがドロップされたら、ホットフォルダーにPDFとして保存するようにしたら良いかな。保存先わからんので、適当に同一階層に書き出すものを用意したので、適当に書き換えれば希望の動作すると思います。

     


    -- 書き出したファイル名に付加する文字(不要なら "" のまま)
    property outputSuffix : ""

    -- true: 元ファイルと同じフォルダに保存 / false: 実行ごとに保存先を確認
    property saveToSameFolder : true

    -- ▼メイン ----------------------------------------------

    on open theFiles
    repeat with anItem in theFiles
    set thisFile to anItem as alias
    set fileInfo to info for thisFile
    set fileExt to name extension of fileInfo

    if fileExt is in {"ai", "eps", "pdf"} then
    my exportToPDFX4(thisFile)
    else
    display dialog "対応外のファイル形式: " & (name of fileInfo) buttons {"OK"} default button 1 with icon caution
    end if
    end repeat
    end open

    on exportToPDFX4(inputFile)
    set inputPath to inputFile as string
    set baseName to my getBaseName(inputPath)
    set inputPosix to POSIX path of inputFile

    if saveToSameFolder then
    set outputFolder to my getContainerFolderPath(inputPath)
    else
    −− この辺でホットフォルダーの指定を行えばOK。このままだとプロンプト表示で保存先を選択
    set outputFolder to (choose folder with prompt "書き出し先フォルダを選択")
    end if

    set outputName to baseName & outputSuffix & ".pdf"
    set outputPath to (outputFolder as string) & outputName
    set outputPosix to my hfsToPosix(outputPath)

    set jsScript to my buildExportScript(inputPosix, outputPosix)

    tell application "Adobe Illustrator"
    activate
    try
    do javascript jsScript
    on error errMsg
    display dialog "PDF/X-4書き出し中にエラーが発生しました" & return & return & "エラー内容: " & errMsg buttons {"OK"} default button 1 with icon stop
    return
    end try
    end tell

    display notification "書き出し完了: " & outputName with title "PDF/X-4 書き出し"
    end exportToPDFX4

    on buildExportScript(inPosix, outPosix)
    set inEsc to my escapeForJS(inPosix)
    set outEsc to my escapeForJS(outPosix)

    set jsLines to {}
    set end of jsLines to "(function(){"
    set end of jsLines to " var srcFile = new File(\"" & inEsc & "\");"
    set end of jsLines to " var doc = app.open(srcFile);"
    set end of jsLines to " var opts = new PDFSaveOptions();"
    set end of jsLines to " opts.pDFXStandard = PDFXStandard.PDFX42007;"
    set end of jsLines to " opts.compatibility = PDFCompatibility.ACROBAT7;"
    set end of jsLines to " opts.preserveEditability = false;"
    set end of jsLines to " opts.generateThumbnails = true;"
    set end of jsLines to " opts.viewAfterSaving = false;"
    set end of jsLines to " if (doc.documentColorSpace == DocumentColorSpace.CMYK) {"
    set end of jsLines to " opts.colorDestinationID = ColorDestination.COLORDESTINATIONDOCCMYK;"
    set end of jsLines to " } else {"
    set end of jsLines to " opts.colorDestinationID = ColorDestination.COLORDESTINATIONDOCRGB;"
    set end of jsLines to " }"
    set end of jsLines to " opts.colorProfileID = ColorProfile.INCLUDEDESTPROFILE;"
    set end of jsLines to " opts.colorConversionID = ColorConversion.None;"
    set end of jsLines to " opts.outputConditionID = \"Custom\";"
    set end of jsLines to " var outFile = new File(\"" & outEsc & "\");"
    set end of jsLines to " doc.saveAs(outFile, opts);"
    set end of jsLines to " doc.close(SaveOptions.DONOTSAVECHANGES);"
    set end of jsLines to "})();"

    set AppleScript's text item delimiters to linefeed
    set jsScript to jsLines as string
    set AppleScript's text item delimiters to ""
    return jsScript
    end buildExportScript

    on escapeForJS(theText)
    set theText to my replaceText(theText, "\\", "\\\\")
    set theText to my replaceText(theText, "\"", "\\\"")
    return theText
    end escapeForJS

    on replaceText(sourceText, searchStr, replaceStr)
    set AppleScript's text item delimiters to searchStr
    set theItems to text items of sourceText
    set AppleScript's text item delimiters to replaceStr
    set resultText to theItems as string
    set AppleScript's text item delimiters to ""
    return resultText
    end replaceText

    on getBaseName(fullPath)
    set AppleScript's text item delimiters to ":"
    set pathItems to text items of fullPath
    set fileName to item -1 of pathItems
    set AppleScript's text item delimiters to "."
    set nameItems to text items of fileName
    if (count of nameItems) > 1 then
    set baseName to items 1 thru -2 of nameItems as string
    else
    set baseName to fileName
    end if
    set AppleScript's text item delimiters to ""
    return baseName
    end getBaseName

    on getContainerFolderPath(fullPath)
    set AppleScript's text item delimiters to ":"
    set pathItems to text items of fullPath
    set folderItems to items 1 thru -2 of pathItems
    set AppleScript's text item delimiters to ":"
    set folderPath to (folderItems as string) & ":"
    set AppleScript's text item delimiters to ""
    return folderPath
    end getContainerFolderPath

    on hfsToPosix(hfsPath)
    return POSIX path of (hfsPath as string)
    end hfsToPosix

     

    どのみちIllustratorで開いて保存して閉じるが必要なので画面上はバタバタします。

    Participant
    August 19, 2026

    ありがとうございます。

    参考にさせていただきます。

    katayanagi51
    Community Expert
    Community Expert
    August 17, 2026

    事情がわからないので外しているかもしれませんが,「AutomatorでaiファイルをPDF(X4が望ましい)に変換」は,「Automatorで拡張子 .pdfを付加」でよいかもしれません。

    これが通用しない .aiファイルは結局,Illustratorで開いてPDF保存(書き出し)を行わないといけないように思います。

    思いつきです。他の識者の回答を待ってみてください。

     

    (参考)

    Adobe Illustratorの「PDF互換ファイルを作成」って何?

    Participant
    August 19, 2026

    コメントありがとうございます。

    参考にさせていただきます。