5 Replies Latest reply on Apr 19, 2016 11:48 PM by SubbaiyaArasu

    Write Para and character styles in txt file

    SubbaiyaArasu Level 1

      Hi All,

       

      I am very beginner in inDesign scripting and i just practicing the basic scripts.

       

       

      i use the below code for collecting all the paragraph and character styling.

      is this correct and secured way to collect all styles? can any one suggest me.

       

      app.activeDocument.paragraphStyles[i].name;
      app.activeDocument.characterStyles[i].name;
      

      ----

      My Full script

      var doc=app.activeDocument;
      var docPath = doc.filePath.fsName;
      
      var paraCount=doc.paragraphStyles.length;
      var charcount=doc.characterStyles.length;
      
      writeFile ();
      
      function writeFile(){
      
      var fh=File(docPath+"\\StyleList.txt");
      fh.open("w");
      if(fh!=-1){
      
      //Paragraph style list Append
          var strgP="";
          for(var i=0; i < paraCount; i++){
              var k=i+1;
              var styleName = doc.paragraphStyles[i].name;
              strgP += "Para style No " +k +": "+styleName + "\n";
          }
      
      //character style list append
          var strgC="";
          for(var i=0; i < charcount; i++){
              var k=i+1;
              var styleName = doc.characterStyles[i].name;
              strgC += "Char style No " +k +": "+styleName + "\n";
          }
      
          fh.write(strgP +"\n\n"+ strgC);
          fh.close();
          }
      
      else{
          alert("Style file not created ...");
         }
      }
      

       

       

      Thanks in Advance,

      Arasu