1 Reply Latest reply on Aug 6, 2012 12:00 PM by csm_phil

    [JS, ID5] Change fontStyle

    stoereee Level 1



      I have the following script for changing character overrides (bold) for character styles:


      app.findTextPreferences = null;
      app.changeTextPreferences = null;
      app.findTextPreferences.fontStyle = "Bold";
      app.changeTextPreferences.appliedCharacterStyle = "Bold";


      The problem is that paragraph styles containing the font style "bold" as a preset, also get's the character style "bold" assigned.

      The script has to skip the predefined -bold made- paragraph styles!?


      Regards, Sjoerd

        • 1. Re: [JS, ID5] Change fontStyle
          csm_phil Level 4

          Hi Sjord,


          Please try the below JS code, I have test the code in CS5.5 its working fine.



          var myDoc = app.activeDocument;
          app.findTextPreferences = app.changeTextPreferences = null;
          app.findTextPreferences.fontStyle = "Bold";
          var mySearch = myDoc.findText();
          for(var i=mySearch.length-1; i>=0; i--){
              var myStyle = mySearch[i].appliedParagraphStyle;
              // Note: the below font style not in Bold then the script will apply the bold character style. If the heading has applied in Bold Condensed or something etc. This script will not work. Please take care.
              if(myStyle.fontStyle != "Bold"){
                  mySearch[i].appliedCharacterStyle = myDoc.characterStyles.item("Bold");