应用程序 AppleScripts 示例

打开脚本:使用文档首选项

要使用文档首选项来打开一个文档,将如下内容指定为自定义的"打开"脚本并在第一个参数中输入"yes"。

on run {args} 
  set theJobPath to infile of args 
  set theDocPrefs to arg1 of args 
  set scriptResult to "/OK/" 
  tell application "QuarkXPress" 
    try 
      if (theDocPrefs is equal to "yes") then 
        open alias theJobPath use doc prefs yes remap fonts no do auto picture import no 
      else 
        open alias theJobPath use doc prefs no remap fonts no do auto picture import no 
      end if 
    on error errmsg number errnum 
      set scriptResult to ("/ERROR/:" & errmsg) 
    end try 
  end tell 
  return scriptResult 
end run

命令脚本:颠倒文档中的页面顺序

要颠倒文档中的页面顺序,将如下内容指定为自定义的"命令"脚本。该脚本不使用任何参数。

on run {args} 
  set scriptResult to "/OK/" 
  tell application "QuarkXPress" 
    try 
      if not (exists document 1) then error "No open document" 
      tell document 1 
        set pageCnt to count of page 
        if pageCnt is not equal to 1 then 
          repeat with i from 1 to pageCnt 
            move page pageCnt to before page i 
          end repeat 
        end if 
      end tell 
    on error errmsg number errnum 
      set scriptResult to ("/ERROR/:" & errmsg) 
    end try 
  end tell 
  return scriptResult 
end run

另存为脚本:保存为多文件 DCS

要将一个文档保存为多文件 DCS,将如下内容指定为自定义的"另存为"脚本(使用一个编译好的脚本)。该脚本使用第一个参数指定色彩设置项("灰度"、"复合 RGB"、"复合 CMYK"、"复合 CMYK 和专色"、"保持原样")。

on run {args} 
  set theOutputSetup to arg1 of args 
  set theResultJobPath to "/ERROR/:Unknown error" 
 
  using terms from application "PowerSwitch_Service" 
    tell application (server of args) 
      try 
        set theJob to jobobject of args 
        set theJobProper to proper name of theJob 
        set theResultJobPath to create path theJob name theJobProper with creating folder 
      on error errmsg number errnum 
        set theResultJobPath to ("/ERROR/:" & errmsg) 
        return theResultJobPath 
      end try 
    end tell 
  end using terms from 
 
  tell application "QuarkXPress" 
    try 
      if not (exists document 1) then error "No open document" 
      tell document 1 
        set pageCnt to count of pages 
        repeat with i from 1 to count of pages 
 
          -- Create the sequential number for the file 
          set fileNum to i 
          repeat until (length of (fileNum as text)) = (length of (pageCnt as text)) 
            set fileNum to "0" & fileNum 
          end repeat 
 
          set FileName to theJobProper & "_" & fileNum & ".eps" 
          set theResultPath to theResultJobPath & ":" & FileName 
 
          save page i in theResultPath EPS format Multiple File DCS EPS data binary EPS scale 100 Output Setup theOutputSetup with transparent page 
        end repeat 
      end tell 
      close document 1 without saving 
    on error errmsg number errnum 
      set theResultJobPath to ("/ERROR/:" & errmsg) 
    end try 
  end tell 
 
  return theResultJobPath 
end run