4 Replies Latest reply on Dec 5, 2014 2:54 AM by steverocket2

    find a column widh

    VeluVK

      Hi,

       

      How to find a table column width in script; i need to find out the first column width.

       

      Regards,

        • 1. Re: find a column widh
          Jaswin Level 1

          var column = app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().getElements() ,linewidth = [];

          var lines = column[i].lines;

          linewidth.push(lines[0].endHorizontalOffset - lines[0].horizontalOffset);

          alert(Math.max.apply(null,linewidth));

          • 2. Re: find a column widh
            csm_phil Level 4

            Hi VeluVK,

             

            try the below js code, you can change the measurement values what you need (picas, points, mm, etc.,).

             

            var myDoc = app.activeDocument;
            var myTables = myDoc.stories.everyItem().tables.everyItem().getElements();
            for (i =0; i<myTables.length; i++){
                var myFirstColumn = myTables[i].columns[0];
                if(myFirstColumn.width <=200){// based on your column width checks
                    alert(myFirstColumn.cells.everyItem().contents);
                    };
                }
            

             

             

            thx,

            csm_phil

            • 3. Re: find a column widh
              Peter Kahrel Adobe Community Professional & MVP

              Why do you guys make it so complicated? All VeluVK want to know is how to find the width of a column. That's

               

              myTable.columns[0].width

               

              If you think he should have checked the object model for himself, then say so.

              • 4. Re: Re: find a column widh
                csm_phil Level 4

                Hi Peter,

                 

                As you suggest, I just modified the js code. thanks for highlighted this!!

                 

                1. directly to get the 1st column width for every tables.

                var myDoc = app.activeDocument;  
                var myTables = myDoc.stories.everyItem().tables.everyItem().columns[0].width;
                alert(myTables)
                

                 

                2. here loop all the tables and get the 1st column width.

                var myDoc = app.activeDocument;  
                var myTables = myDoc.stories.everyItem().tables.everyItem().getElements();  
                for (i =0; i<myTables.length; i++){  
                    var myFirstColumn = myTables[i].columns[0].width;
                    alert(myFirstColumn)
                    }  
                

                 

                 

                thx,

                csm_phil

                • 5. Re: find a column widh
                  steverocket2 Level 1

                  Hi,

                  I have run into situations where I had to consider the stroke width left an right of the table. You might have to add that to your calculation of the column width.

                   

                  Thanks Stefan