InDesign脚本:过去到框架

问题描述:

我正在处理一个脚本,它将剪贴板粘贴到每个选定的框架中。经过四周搜索,我没有弄清楚如何将东西粘贴到框架(或多边形)。InDesign脚本:过去到框架

我被堵在这样的事情:

function pasteSelection(mySelection) { 
    for (var i = mySelection.length - 1; i > -1; i--) { 
     mySelection[i].contents = app.paste(); 
    } 
} 

我应该mySelection[i].contents = app.paste()是什么?

根据another answer I provided not long ago,这会有所帮助。对于这个片段来粘贴任何东西,你必须在你的文档中选择TEXT。这就是这个片段知道粘贴的地方。

var myDoc = app.activeDocument; 

if(app.documents.length != 0){ 
    if(app.selection.length == 1){ 
     try{   
      var frame1 = app.selection[0]; 
      frame1 = app.paste();//works 
      //app.pasteWithoutFormatting(frame1);;works too 
     } 
     catch(e){ 
      alert ("Exception : " + e, "Exception"); 
     } 
    } 
else{ 
    alert ("Please select text", "Selection"); 
    } 
} 
else{ 
    alert("Something wrong"); 
} 

更新以下评论: 对于这个片段我创建到我创建了2个对象InDesign文档。一个对象是一个文本框,我在其中输入了一堆文本,第二个项目仅仅是我绘制在文本框下面的一个多边形。我没有设置多边形的内容类型,我只是画了多边形。为了有效地找到我真正想要和需要的页面项,我使用Script Labels,但使用标签不是必需的。只要你有一种机制知道你正在处理正确的对象。

这段代码背后的想法很简单:

  1. Select the Source object
  2. Copy the selected object
  3. Select the Destination object
  4. Paste into the selected object

var myDoc = app.activeDocument; 
var source; 
var destination; 

for(var i = 0; i < myDoc.pageItems.length; i++) 
{ 
    if(myDoc.pageItems[i].label == "source") 
    { 
     source = myDoc.pageItems[i]; 
     app.selection = myDoc.pageItems[i]; 
     app.copy(); 
     } 
    else if(myDoc.pageItems[i].label == "destination") 
    { 
     destination = myDoc.pageItems[i]; 
     } 

    if(source !== undefined && destination !== undefined) 
    { 
     break; 
     } 
} 
app.selection = destination; 
app.pasteInto(); 
+0

使用哪个命令可以直接将我的剪贴板**插入到**多边形中?例如。我选择一个多边形,运行脚本,之后我将一个文本框粘贴到该多边形中。 – Malte

+0

@Malte,已更新 –

+0

谢谢!关键是我不知道的app.pasteInto()。我正在使用'app.paste()' – Malte