【问题标题】:How get Adobe InDesign HyperLinkURLDestination linked text如何获取 Adob​​e InDesign HyperLinkURLDestination 链接文本
【发布时间】:2016-06-16 12:02:47
【问题描述】:

到目前为止,我实现了一个将 InDesign 文档导出为 XML 的扩展,除了超链接之外一切正常。

我可以通过 document.hyperlinkURLDestination 获取所有超链接 (HyperLinkURLDestination),但无法知道段落中的哪些文本链接到这些超链接。有什么想法吗?

【问题讨论】:

    标签: adobe adobe-indesign


    【解决方案1】:

    超链接基本上有两个属性,源和目标。您的案例中的目的地是要在浏览器中打开的 url。然而,源实际上是一个 InDesign 文本对象。目的地可以多次使用,但每个对象只能使用一次来源。所以我建议通过实际使用它的对象访问文本源,即超链接。

    var main = function() {
    	var doc = app.properties.activeDocument,
    	hlks,hlk,
    	src,
    	txt;
    	
    	if ( !doc) return;
    	
    	hlks = doc.hyperlinks;
    	
    	
    	if ( !hlks.length ) return;
    	
    	hlk = hlks[0];
    	src = hlk.source;
    	
    	if ( !( src instanceof HyperlinkTextSource) ) return;
    	txt = src.sourceText;
    	app.select ( txt );
    	
    	txt.parentTextFrames.length && zoomObject ( txt.parentTextFrames[0] );
    	
    	alert( "here you are…");
    }
    
    
    function zoomObject(theObj) {
     try {
      var objBounds = theObj.geometricBounds;
     } catch (e) {
      throw "Object doesn't have bounds."
     }
     var ObjHeight = objBounds[2] - objBounds[0];
     var ObjWidth = objBounds[3] - objBounds[1];
     var myWindow = app.activeWindow;
     var pageBounds = myWindow.activePage.bounds;
     var PgeHeight = pageBounds[2] - pageBounds[0];
     var PgeWidth = pageBounds[3] - pageBounds[1];
     var hRatio = PgeHeight/ObjHeight;
     var wRatio = PgeWidth/ObjWidth;
     var zoomRatio = Math.min(hRatio, wRatio);
     myWindow.zoom(ZoomOptions.fitPage);
     myWindow.zoomPercentage = myWindow.zoomPercentage * zoomRatio;
    }
    
    main();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-01
      • 2011-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-10
      • 2010-12-03
      • 2012-01-23
      相关资源
      最近更新 更多