![](/img/trans.png)
[英]Loop through all threadded text frames in JavaScript InDesign script?
[英]How to find ALL text frames in InDesign by JavaScript
我需要在 InDesign 文档中找到活动页面上的所有文本框并将它们放入一个数组中 - 以便抓取一个或多个带有特定脚本标签的文本框。 我试过了
myPage = app.properties.activeWindow && app.activeWindow.activePage,
myTextFrames = myPage.textFrames.everyItem().getElements();
但这不会带来那些锚定的文本框架; - 在表格单元格中; - 在一个组内。 我怎样才能得到真正的所有文本框?
不在一行。
您可能需要从myPage.allPageItems
--> 开始,它返回一个数组并通过
arrayElement.constructor.name == "TextFrame"
要么
arrayElement.label == "yourTargetLabel"
//Array of every single pageItem in the document var myItems = doc.allPageItems; var n = myItems.length, tfs = [], nItem; //Looping through page items to collect text frames while ( n-- ) { nItem = myItems[n]; (nItem instanceof TextFrame) && tfs.push ( nItem ); } //result alert( tfs.length + " textframes have been found" );
你也可以通过处理故事来反其道而行之:
//Storing all stories in the document. var stories = doc.stories.everyItem().getElements(), n = stories.length, nStory, tfs = []; //looping through stories to collect text frames while ( n-- ) { nStory = stories[n]; tfs.concat ( nStory.textContainers ); } //result alert( tfs.length + " textframes have been found" );
这可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.