简体   繁体   中英

indesign scripting - find textarea, add text & apply styles

Want to apply a script to find a text area, give it some text and change the colour of the text

Here i have added the text but dont know which attributes change the colour:

myFrame = app.activeDocument.textFrames.itemByName("test");
myFrame.contents = "hello world";
var color = myDocument.colors.add();
color.properties = { model : ColorModel.PROCESS, space : ColorSpace.RGB, colorValue :[0,0,0]}

var paraStyle = app.activeDocument.paragraphStyles.add();
paraStyle.fillColor = color;
paraStyle.fontSize = 32;
paras = myFrame.paragraphs;
for (i =0 ; i< paras.length, i++){
   paras[i].appliedParagraphStyle = paraStyle;
}

Just in case you what to do what to apply style to a range of para(character style)

var charStyle = myDocument.characterStyles.add();
charStyle.fillColor = color;
paras[i].characters.itemByRange(0, 10).appliedCharacterStyle = charStyle;

For further details of the available properties refer: http://jongware.mit.edu/idcs6js/pc_ParagraphStyle.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM