admin管理员组文章数量:1432566
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?
2 Answers
Reset to default 3Ok, 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.
本文标签:
版权声明:本文标题:How to find a text frame in Indesign CS6 with javascript? (I can query by text-frames containing a particular paragraph style or 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745584511a2664817.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论