• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to apply character style whit script

Community Beginner ,
Jan 03, 2018 Jan 03, 2018

Copy link to clipboard

Copied

Hi, is possible to apply a charter and paragraph style without writing it on a text frame?

I have a for loop that add text to var and I need to map it with styles, something like this:

var myText = '';

var content = {

     'one': 'lorem ipsum',

     'two': 'dolor sit amet',

     'three' : 'consectetur adipiscing elit'

     'four' : 'Mauris ut sem id nisi malesuada',

}

for(key in content){

     if(key=='one'){

          myText += content[key] //and map with character style styleONE

     }else if(key == 'two'){

          myText += content[key] //and map with character style styleTWO

     }

     ....etc

}

var myTextFrame = app.selection[0].insertionPoints[0];

myTextFrame = myText;

So I would to create the var string already mapped with styles and then write it to a text Frame.

Actualy I'm doing this

var myTextFrame = app.selection[0].insertionPoints[0];

myTextFrame = ' ';

var content = {

     'one': 'lorem ipsum',

     'two': 'dolor sit amet',

     'three' : 'consectetur adipiscing elit'

     'four' : 'Mauris ut sem id nisi malesuada',

}

for(key in content){

     if(key=='one'){

        myTextFrame.parentStory.characters.item(-1).applyCharacterStyle(stileCarGiorno,true);

        myTextFrame.parentStory.insertionPoints.item(-1).contents=thisDay['giorno'];

          myTextFrame += content[key]

     }else if(key == 'two'){

          myTextFrame += content[key] //and map with character style styleTWO

     }

     ....etc

}

TOPICS
Scripting

Views

292

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2018 Jan 03, 2018

Copy link to clipboard

Copied

Moving to InDesign Scripting forum

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 03, 2018 Jan 03, 2018

Copy link to clipboard

Copied

LATEST

Excuse me, the post was published by mistake while I was still writing it. It's incomplete but now I can't modify it.

So I repeat and correct the question.

I have a for loop that add text to var and I need to map it with styles, something like this:

var myText = '';

var content = {

    'one': 'lorem ipsum',

    'two': 'dolor sit amet',

    'three' : 'consectetur adipiscing elit'

    'four' : 'Mauris ut sem id nisi malesuada',

}

for(key in content){

    if(key=='one'){

          myText += content[key] //and map with character style styleONE

    }else if(key == 'two'){

          myText += content[key] //and map with character style styleTWO

    }

    ....etc

}

var myTextFrame = app.selection[0].insertionPoints[0];

myTextFrame = myText;

So I would to create the var string already mapped with styles and then write it to a text Frame.

Actualy I'm doing this

var myTextFrame = app.selection[0].insertionPoints[0];

myTextFrame = ' ';

var content = {

    'one': 'lorem ipsum',

    'two': 'dolor sit amet',

    'three' : 'consectetur adipiscing elit'

    'four' : 'Mauris ut sem id nisi malesuada',

}

for(key in content){

    if(key=='one'){

        myTextFrame.parentStory.characters.item(-1).applyCharacterStyle(styleONE,true);

        myTextFrame.parentStory.insertionPoints.item(-1).contents=content[key];

        }

    

    ....etc

  

}

I think it would be amazing if I could map text like html or xml

    <charStyle class="one">lorem ipsum</charStyle>

    <charStyle class="two">dolor sit amet</charStyle>

Is it possible?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines