1 Reply Latest reply on Apr 20, 2011 8:29 PM by Ten A

    Toggle style attribute off/on script

    gwhPoster Level 1

      Hi everyone,

       

      I've created a character style that uses a colored underline, is offset and has a very thick stroke weight. The result is an effect that I use to highlight parts of a document's text.

       

      The files I'm working on are located in a books panel and I need to create two types of pdf files. One with the highlight intact and the other with it removed. Up until now, I've had to open up each file within the books panel, then go into the highlight character style and turn the underline off and then make a pdf. Then I have to turn it back on again for the other pdf.

       

      I wondered if there was a script available that I could run, which would target the style within each of the files in the books panel and toggle the underline off or on?

       

      Appreciate any advice.

        • 1. Re: Toggle style attribute off/on script
          Ten A Adobe Community Professional

          At first, you can't access documents properties from book. "characterStyles" properties are Documents children. It mean, You have to open the document before edit properties.
          see below.

           

          filePath = app.activeBook.bookContents[0].fullName;
          f = new File(filePath);
          myDoc = app.open(f);

           

          This sample is open first item in book.
          and you can access underline property like below.

           

          myDoc.characterStyle.itemByName('Style Name').underline = true;

           

          It set to underline. If you want delete it, change value "true" to "false".

           


          for (i=0;i<app.activeBook.bookContents.length;i++){
              filePath = app.activeBook.bookContents[i].fullName;
              f = new File(filePath);
              myDoc = app.open(f);
              myDoc.characterStyles.itemByName('test').underline = true;
              myDoc.close(SaveOptions.YES);
              }

           

          previous script is change value of characterStyle named "test"s underline property of all documents in activeBook.

           

          Ten.