Search code examples
javascriptadobe-indesign

InDesign changing Text Stroke Color with Javascript


I want to change the Color of "Ortsname" in JavaScript, im using:

var relieflackEbene = myDoc.layers.itemByName('Relieflack');

to select the Layer "Relieflack" but when using

relieflackEbene.pageItems.firstItem().strokeColor = "Relieflack";

actually i dont want to use "firstItem()" because it might not be the first item on that Layer. But it is changing the color of the Textbox, not the color of the Text inside it.

InDesign Layer

Any hints?


Solution

  • following code should change stroke color of text "Ortsname".

    for (var i=0, len=relieflackEbene.pageItems.length; i < len ; i++) {
      if (relieflackEbene.pageItems[i].parentStory.contents === "Ortsname") {
        relieflackEbene.pageItems[i].parentStory.strokeColor = "Relieflack"
      }
    };
    

    if you want change at all texts of textframes in the layer, try this

    relieflackEbene.pageItems.everyItem().texts.everyItem().strokeColor = "Relieflack";