最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论