5 Replies Latest reply on Nov 25, 2014 4:52 AM by LearnIndesignScripting

    Only want Bold and Italic Words

    LearnIndesignScripting

      Hi

      I am using this code

              var doc =app.activeDocument;

               var par=doc.stories.everyItem().paragraphs.everyItem().getElements();

                var reportFilePath = doc.fullName.absoluteURI.replace(/\.indd$/i, ".txt");

                var len=par.length;

                 

              

         for(var i=0;i<par.length;i++)

         {

            // var font=par[i].appliedParagraphStyle.name;

              //var font1=par[i].appliedFont.fullName;  

             var AllWords = par[i].words;

              var length=AllWords.length;

              for(var q=0;q<length;q++)

              {

               var size=AllWords[q].fontStyle;

                  if(size=="Bold" || size=="Bold Italic" || size="Italic")

                   {

                       WriteToFile(AllWords[q].contents,reportFilePath);            

                   }

               }

            

          }

       

                      function WriteToFile(text, reportFilePath) {

                      file = new File(reportFilePath);

                      file.encoding = "UTF-8";

                      if (file.exists) {

                          file.open("e");

                          file.seek(0, 2);

                      }

                      else {

                          file.open("w");

                      }

                        file.writeln(text); 

                      file.close();

      }

       

      I want only bold italic words not any other digit and all

       

      Some suggest