Indesign script - How to get first paragraph in threaded text frame

前提是你 提交于 2019-12-13 05:23:33

问题


I have a book with text frames on each page , they are all threaded together, I want to grab hold of each text frames first paragraph, is there any way, I'm trying app.activeDocument.textFrames[0].paragraphs.length and returns "0", only parentStory.paragraphs.length returns the paragraphs but I can't know which are the first in a text frame, any help?


回答1:


You should be able to use the textContainers attribute of Story to get each TextFrame of a story.

var frames = story.textContainers; // Where `story` is your story
for (var i=0; i<frames.length; i++) {
   var frame = frames[i];

   if (!frame.characters.length) continue; // Skip text frames without characters

   var para = frame.paragraphs[0];

   if (para.parentTextFrames.length > 1) {
      para = frame.paragraphs[1];
   }

   // Do work with `para` object
}



回答2:


The text frame's contents will have paragraphs.



来源:https://stackoverflow.com/questions/33467344/indesign-script-how-to-get-first-paragraph-in-threaded-text-frame

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!