![](/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.