3 Replies Latest reply on Dec 30, 2014 8:30 PM by LearnIndesignScripting

    I have a paragrapgh(which we are getting from some paragrapgh style filteration), I want to add a text frame on the paragrapgh location and then cut all the paragrapgh text and paste into that text frame, please help

    LearnIndesignScripting

      Here is my sccript  :

       

       

       

      var MyDoc = app.activeDocument;

      var arrTagContent=new Array();

       

       

      var arrGB=new Array();

       

       

       

       

      MyDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

      MyDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

      var LstStories = MyDoc.stories;

      var LstPara = LstStories.everyItem().paragraphs.everyItem().getElements();

      var arrCollection=new Array();

       

       

        

      var arrObject=new Array();  

        fucGetParagraphs();

        function fucGetParagraphs()

      {

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

           {  

              

                     var styleName=LstPara[i].appliedParagraphStyle.name;    

                     var istrue=getdateRegex(styleName.toLowerCase());

                     if(istrue !=null)

                     {

                         if(LstPara[i].words.length>0)

                         {

                              arrObject.push(LstPara[i]);

                           }

                   

                     }

                 else

                 {

                     if(arrObject.length>0)

                     {

                       var getGB=gemoticBunds(arrObject)

                     

                       var myRectAngle = arrObject[0].parentTextFrames[0].parentPage.textFrames.add ({geometricBounds:[getGB.y1,getGB.x1,getGB.y2,getGB.x2]});    //   this will create textFrames but if some one move a frame it will not up, to text, I want text to be fixed on that text frame

                       myRectAngle.transparencySettings.blendingSettings.opacity=20;

                       myRectAngle.fillColor="C=100 M=0 Y=0 K=0";

                       arrObject=new Array(); 

                

                    }

                  }              

           }       

             

      }

       

       

       

       

      function gemoticBunds(Para)

      {

           var endHOffset=0;

             var HOffset=0;

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

           {

                              var  lines=Para[i].lines;

                              for(var k=0; k<lines.length; k++)

                               {

                                     var x2=lines[k].endHorizontalOffset;

      //~                                     if(k==0)

      //~                                     {

      //~                                     endHOffset=x2;

      //~                                     }

      //~                                 else

      //~                                 {

                                              if(endHOffset>x2)

                                              {

                                                 

                                               }

                                           else

                                           {

                                             endHOffset=x2; 

                                           }

                                       //}                     

                                  

                                      var x1=lines[k].horizontalOffset;

                                          if(k==0)

                                          {

                                          HOffset=x1;

                                          }

                                      else

                                      {

                                              if(HOffset>x1)

                                              {

                                                 

                                               }

                                           else

                                           {

                                             HOffset=x1; 

                                           }

                                       }                  

                                

                                  

                              }                    

                

           }

                   var objGB=new Object();

                  objGB.y1=Para[0].baseline-Para[0].pointSize-1;

                   objGB.y2=Para[Para.length-1].endBaseline +1;

                  objGB.x1=HOffset;

                  objGB.x2=endHOffset;            

                return objGB;

         

      }

       

       

      function getdateRegex(string)

      {

      var text= string.match (/(box)/g);     //  box is a name of para style for which we are filter paragraph

      return text;

      }