【问题标题】:Adding hyperlink to image in Indesign with Applescript使用 Applescript 在 Indesign 中添加图像的超链接
【发布时间】:2019-07-07 07:46:50
【问题描述】:

我正在尝试创建一个 AppleScript,它会在 InDesign 中的每个链接图像上创建超链接。

这是我目前为止的想法。

tell application "Adobe InDesign CC 2017"
  activate
  tell active document
  set grphicBoxs to all graphics of layer activeLayer
  set myLinks to {}
  repeat with I in grphicBoxs
  set iLink to item link of i
  set end of myLinks to iLink
  end repeat

  repeat with theLinkRef in myLinks
  set theLinkName to ((name of theLinkRef) as string)
  display dialog "theLinkName: " & theLinkName

  set myHyperLink to "www.myURL"
  set myHyperLinkName to "myURL name"

  try
  set hyperLinkPreSet to make hyperlink URL destination with properties `{name:myHyperLinkName, destination URL:myHyperLink}`
  on error
  set hyperLinkPreSet to hyperlink URL destination myHyperLinkName
  end try


  try
  set hyperLinkObject to make hyperlink page item source with properties `{name:myHyperLinkName, source page item:rectangle theLinkName, hidden:false}`
  on error
  set TheHS to hyperlink page item source myHyperLinkName
  end try

  display dialog "hyperLinkObject:" & hyperLinkObject

  make new hyperlink with properties `{destination:myHyperLink, source:hyperLinkObject, visible:false}`


  end repeat

  end tell
end tell

预期结果是将创建的超链接预设应用于所选对象。但我收到此错误消息。

方法“make”的参数“source”的值无效。预期页面 项目,但什么也没收到。

这里有谁成功地在链接对象上创建了超链接可以帮助我吗?

【问题讨论】:

    标签: hyperlink applescript adobe-indesign


    【解决方案1】:

    问题解决了

    将 activeLayer 设置为“第 1 层” 将计数器设置为 1

    告诉应用程序“Adobe InDesign CC 2017” 启用 告诉活动文档 将 grphicBoxs 设置为图层 activeLayer 的所有图形 将 myLinks 设置为 {} 在 grphicBoxs 中重复 i 将 iLink 设置为 i 的项目链接 将 myLinks 的结尾设置为 iLink 结束重复

       repeat with theLinkRef in myLinks
           set theLinkName to ((name of theLinkRef) as string)
           set theLinkNameNoext to text 1 thru ((offset of "." in theLinkName) - 1) of theLinkName
    
           set myHyperLink to "http://macscripter.net"
           set myHyperLinkName to theLinkNameNoext & " " & counter
    
           make hyperlink with properties {name:myHyperLinkName, source:make hyperlink page item source with properties {source page item:rectangle counter}, destination:make hyperlink URL destination with properties {destination URL:myHyperLink}}
    
           set counter to counter + 1
       end repeat
    

    结束告诉 结束告诉

    【讨论】:

      猜你喜欢
      • 2017-08-06
      • 2012-05-07
      • 1970-01-01
      • 2021-07-02
      • 1970-01-01
      • 1970-01-01
      • 2017-09-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多