How to find a text frame in Indesign CS6 with javascript? (I can query by text-frames containing a particular paragraph style or

I was looking about indesign scripts and I have not found anything about this topic, which I think is i

I was looking about indesign scripts and I have not found anything about this topic, which I think is important. So here it is my question:

  • How to find a text frame in Indesign CS6 with javascript?
  • I can query by text-frames containing a particular paragraph style?
  • I can set some kind of name on my text-frame (which is in the master page) to get it in javascript?

I was looking about indesign scripts and I have not found anything about this topic, which I think is important. So here it is my question:

  • How to find a text frame in Indesign CS6 with javascript?
  • I can query by text-frames containing a particular paragraph style?
  • I can set some kind of name on my text-frame (which is in the master page) to get it in javascript?
Share Improve this question asked Mar 5, 2013 at 15:02 Totty.jsTotty.js 15.9k31 gold badges111 silver badges179 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Ok, after some research I've found that you can set a label to an object by opening the "Script label", selecting the object you want and the write the label-name into the "Script label" panel. You don't have to click ok or nothing, it will automatically save the label for that object.

After you do that, you can check the ".label" property on objects and when you will find the object with that label, you found it. Multiple objects can have the same label.

Below is an example with a helper function "selectWhere":

var document = app.documents.item(0); // active document
var allTextFrames = toArray(document.textFrames);
var textFrames = selectWhere("chapterLetter", "label", allTextFrames);

function selectWhere(value, key, array){
    var i = array.length; var t; var filtered = [];
    while(i--){
            t = array[i];
            if(t && t[key] == value){
                filtered.push(t);
            }
    }
    return filtered;
}

function toArray(objects){
    var i = objects.length; var array = [];
    while(i--){
            array.push(objects[i]);
    }
    return array;
}

1)The answer to your first question is:- solved in this thread

2)Now you get array of textframes.So you can query to get the paragraph style on the text frames

var paraStyle1 = app.activeDocument.paragraphStyles.itemByName("styleA");
    var paraStyle2 = app.activeDocument.paragraphStyles.itemByName("styleB");
  if (paraStyle1.isValid && paraStyle2.isValid) 

3) Through paraStyle1.name you can get the name of the style.See parastyle1 is the paragraph style object so get the style object and find by this property.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745584512a4634451.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信