7 Replies Latest reply on Sep 30, 2014 1:54 AM by Abdullatif Junaid

    Is there any way to convert the selected rows to text in javascript??

    Abdullatif Junaid

      Hi All,

       

      I have place some word file to indesign cs 5.5 it is almost in one table, i need to separate the text from the real tables, Is there any way to convert the selected rows to text in javascript??

       

      If there is no way to make that, any one can help me to make a script to cut the selected rows and place it in privies pointer of the table to make it independent table and after that convert it to text ?

        • 1. Re: Is there any way to convert the selected rows to text in javascript??
          Sajeev Sridharan Level 4

          Try this,

           

          app.activeDocument.textFrames.everyItem().tables.everyItem().convertToText("\t","\r");

           

          Vandy

          • 2. Re: Is there any way to convert the selected rows to text in javascript??
            Abdullatif Junaid Level 1

            But this convert all table not only what i select of rows

            • 3. Re: Is there any way to convert the selected rows to text in javascript??
              dulajun Level 2

              Hi my brother,

               

              Just select the rows or cells represent the rows and then execute this Javascript snippet:

               

              for (var r = 0; r < app.selection.length; r++) {
                  for (var t = 0; t < app.selection[r].rows.length; t++) {
                      for (var u = 0; u < app.selection[r].rows[t].cells.length; u++) {
                          for (var c = 0; c < app.selection[r].rows[t].cells[u].paragraphs.length; c++) {
                              app.selection[r].rows[t].cells[u].paragraphs[0].move (LocationOptions.AFTER, app.selection[r].rows[t].parent.parent.storyOffset);
                              if (c < app.selection[r].rows[t].cells[u].paragraphs.length - 1)
                                  app.selection[r].rows[t].parent.parent.storyOffset.contents += "\r";
                          }
                          if (u < app.selection[r].rows[t].cells.length - 1) {
                              app.selection[r].rows[t].parent.parent.storyOffset.contents += "\t";
                          }
                          else {
                              app.selection[r].rows[t].parent.parent.storyOffset.contents += "\r";
                          }
                      }
                  }
              }
              for (var r = 0; r < app.selection.length; r++) {
                  for (var t = app.selection[r].rows.length - 1; t >= 0; t--) {
                      app.selection[r].rows[t].remove ();
                  }
              }
              
              • 5. Re: Is there any way to convert the selected rows to text in javascript??
                Abdullatif Junaid Level 1

                The previous script is really perfect to me, and i need other one, if you can help me i need to do place the text after the table.

                • 6. Re: Is there any way to convert the selected rows to text in javascript??
                  dulajun Level 2

                  This insert the rows contents after the table instead of being before:

                   

                  for (var r = app.selection.length - 1; r >= 0; r--) {

                      for (var t = app.selection[r].rows.length - 1; t >= 0; t--) {

                          for (var u = app.selection[r].rows[t].cells.length - 1; u >= 0; u--) {

                              for (var c = app.selection[r].rows[t].cells[u].paragraphs.length - 1; c >= 0; c--) {

                                  app.selection[r].rows[t].cells[u].paragraphs[0].move (LocationOptions.AFTER, app.selection[r].rows[t].parent.parent.storyOffset.parent.insertionPoints.nextItem(app.se lection[r].rows[t].parent.parent.storyOffset));

                                  if (c != 0)

                                      app.selection[r].rows[t].parent.parent.storyOffset.parent.insertionPoints.nextItem(app.se lection[r].rows[t].parent.parent.storyOffset).contents += "\r";

                              }

                              if (u != 0) {

                                  app.selection[r].rows[t].parent.parent.storyOffset.parent.insertionPoints.nextItem(app.se lection[r].rows[t].parent.parent.storyOffset).contents += "\t";

                              }

                              else {

                                  app.selection[r].rows[t].parent.parent.storyOffset.parent.insertionPoints.nextItem(app.se lection[r].rows[t].parent.parent.storyOffset).contents += "\r";

                              }

                          }

                      }

                  }

                  for (var r = 0; r < app.selection.length; r++) {

                      for (var t = app.selection[r].rows.length - 1; t >= 0; t--) {

                          app.selection[r].rows[t].remove ();

                      }

                  }

                  • 7. Re: Is there any way to convert the selected rows to text in javascript??
                    Abdullatif Junaid Level 1

                    Thank you very much it work good but there is some space "app.se lection" in some lines

                     

                    Screenshot 2014-09-30 11.48.34.png