22 Replies Latest reply on Apr 6, 2016 1:49 AM by Suzan.V
      • 1. Re: Text wrap bottom offset-by script
        Kasyan Servetsky Level 5

        Here's an example:

         

        var frame = app.selection[0];
        frame.textWrapPreferences.textWrapOffset = [0, 0, "4 mm", 0];
        
        • 2. Re: Text wrap bottom offset-by script
          hasvi Level 1

          thanks

          how to get input value of 'textwrap bottom offset'. Because I have to add default 1pica in bottom offset for all the provided indesign file.

           

          by

          hasvi

          • 3. Re: Text wrap bottom offset-by script
            Harbs. Level 6

            The bottom offset is the third value on the array. The array is top,left,bottom,right.

            • 4. Re: Text wrap bottom offset-by script
              hasvi Level 1

              hi,

               

              how to find this 'frame.textWrapPreferences.textWrapOffset' throughout indesign files, is this possible by script?

               

              by

              hasvi

              • 5. Re: Text wrap bottom offset-by script
                Chinnadk Level 4

                Hi Hasvi,

                 

                Try this.

                 

                var txfms =  app.activeDocument.pages.everyItem().textFrames.everyItem().getElements();

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

                {

                        txfms[i].textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;

                        txfms[i].textWrapPreferences.textWrapOffset = [0, 0, "4 mm", 0];

                    }

                 

                Regards,

                Chinna

                • 6. Re: Text wrap bottom offset-by script
                  hasvi Level 1

                  Hi Chinna,

                   

                  your script is working for all the textframes in indesign, but I need text wrap adjustment in 'image with caption' text frame only (marked in green color). Please see the snapshot for your reference.

                   

                  First I want to search which page has "text wrap bottom offset in 'image with caption' text frame", Then I want to apply default 4mm bottom offset in 'txfms[i].textWrapPreferences.textWrapMode = TextWrapModes.JUMP_OBJECT_TEXT_WRAP;'Is this possible by script.

                  image with caption textframe.png

                  by

                  hasvi

                  • 7. Re: Text wrap bottom offset-by script
                    hasvi Level 1

                    Hi Chinna,

                     

                    I am going to add default 1pica in 'txfms[i].textWrapPreferences.textWrapOffset = [0, 0, "4 mm(consider this is input value)"+1p(here I want to add default 1p), 0];'. So what is the statement for get input value in below:

                     

                            txfms[i].textWrapPreferences.textWrapOffset = [0, 0, "4 mm", 0];

                     

                    by

                    hasvi

                    • 8. Re: Text wrap bottom offset-by script
                      Chinnadk Level 4

                      Hi Hasvi,

                       

                      If you want to give textwrapoffset to the frame which has only image caption than put it into a separate layer or give a name to it via script label, then get them into a loop and give textwrapoffset.

                       

                      Use the below code to add 1pica to bottom the offset,

                       

                      var doc =app.activeDocument;

                      var txfms =  app.activeDocument.pages.everyItem().textFrames.everyItem().getElements();

                      var oldhm = doc.viewPreferences.horizontalMeasurementUnits;

                      var oldvm = doc.viewPreferences.verticalMeasurementUnits;

                      doc.viewPreferences.horizontalMeasurementUnits = doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.picas;

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

                      {

                           

                              var tf = txfms[i].textWrapPreferences.textWrapOffset;

                              txfms[i].textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;

                              txfms[i].textWrapPreferences.textWrapOffset = [0, 0, tf[2] + 1, 0];

                          }

                      doc.viewPreferences.horizontalMeasurementUnits = oldhm;

                      doc.viewPreferences.verticalMeasurementUnits = oldvm;

                       

                      Regards,

                      Chinna

                      • 9. Re: Text wrap bottom offset-by script
                        Jump_Over Level 5

                        Hi,

                         

                        In case of many various unit operation it could be easier to use unit.convert() method.

                        Example:

                        nValue = new UnitValue(1,"picas");

                        nValue.convert("mm");

                        //...

                        txfms[i].textWrapPreferences.textWrapOffset = [0, 0, tf[2] + nValue.value, 0];

                        //...

                         

                        Jarek

                        • 10. Re: Text wrap bottom offset-by script
                          hasvi Level 1

                          Hi Chinna,

                           

                          Its working fine, but below error shows when running, and command is "Object does not support the property or method '2'"

                          see this.png

                          hi can you explain me what is "tf[2]" here.

                           

                          by

                          hasvi

                          • 11. Re: Text wrap bottom offset-by script
                            Chinnadk Level 4

                            Hi,

                             

                            Re-order the below lines.

                             

                            txfms[i].textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;

                            var tf = txfms[i].textWrapPreferences.textWrapOffset;

                            txfms[i].textWrapPreferences.textWrapOffset = [0, 0, tf[2] + parseFloat("1p"), 0];

                             

                             

                            txfms[i].textWrapPreferences.textWrapOffset returns array of four units [top, left, bottom, right] here tf[0] is top, tf[1] is left, tf[2] is bottom, tf[3] is right.

                             

                            Regards,

                            Chinna

                            • 12. Re: Text wrap bottom offset-by script
                              hasvi Level 1

                              Hi chinna,

                               

                              Thanks for your information, as you said we have follow this in script lable or layer option. Now I have used with script lable, So text wrap option applied for 'image box with caption' and as well as my total 'text frame'.

                               

                              BUt I need text wrap only for 'image box with caption', So is this possible in layer option? pls help

                               

                               

                              by

                              hasvi

                              • 13. Re: Text wrap bottom offset-by script
                                Chinnadk Level 4

                                Hi Hasvi,

                                 

                                For accessing via script label replace the below lines in for loop.

                                 

                                if(txfms[i].label == "caption")//Give "caption" as a name for all the caption frames via script label

                                     {

                                        txfms[i].textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;

                                        var tf = txfms[i].textWrapPreferences.textWrapOffset;

                                        txfms[i].textWrapPreferences.textWrapOffset = [0, 0, tf[2] + 1, 0];

                                        }

                                 

                                For accessing via layers replace the below lines in for loop.

                                 

                                if(txfms[i].itemLayer == doc.layers.item("caption"))//create a layer named "caption" and move the caption frame into it

                                    {

                                        txfms[i].textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;

                                        var tf = txfms[i].textWrapPreferences.textWrapOffset;

                                        txfms[i].textWrapPreferences.textWrapOffset = [0, 0, tf[2] + 1, 0];

                                        }

                                 

                                Regards,

                                Chinna

                                • 14. Re: Text wrap bottom offset-by script
                                  hasvi Level 1

                                  Hi chinna,

                                   

                                  your answers are very very useful for us.

                                   

                                  by

                                  hasvi

                                  • 15. Re: Text wrap bottom offset-by script
                                    hasvi Level 1

                                    Hi chinna,

                                     

                                    this is the code:

                                     

                                    if((globBaseLineDiff!=0) && myTextWrap.textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP)

                                                {

                                                var tf = myTextWrap.textWrapPreferences.textWrapOffset;

                                                myTextWrap.textWrapPreferences.textWrapOffset = [tf[0], tf[1], tf[2]+ globBaseLineDiff, tf[3]];

                                            }

                                     

                                    FYI see snapshot:

                                    Before script:

                                    before script.png

                                     

                                    After script:

                                    after script.png

                                     

                                    I am inserting space in 'Bottom Offset' only, but after running my script 'Top Offset & Left Offset & Right Offset' value getting to 0. Here how to retain my input value in this bold place

                                     

                                    myTextWrap.textWrapPreferences.textWrapOffset = [tf[0], tf[1], tf[2]+ globBaseLineDiff, tf[3]];

                                     

                                    by

                                    hasvi

                                    • 16. Re: Text wrap bottom offset-by script
                                      hasvi Level 1

                                      Hi chinna,

                                       

                                      Are you there?

                                       

                                      by

                                      hasvi

                                      • 17. Re: Text wrap bottom offset-by script
                                        hasvi Level 1

                                        Hi,

                                         

                                        I am using this condition only for "JUMP_OBJECT_TEXT_WRAP"

                                         

                                        if((mypageDiff!=0) && (myTextWrap.textWrapPreferences.textWrapMode = TextWrapModes.JUMP_OBJECT_TEXT_WRAP))

                                         

                                        but its alpplied for--TextWrapModes.BOUNDING_BOX_TEXT_WRAP also how can we control it?

                                         

                                        by

                                        hasvi

                                        • 18. Re: Text wrap bottom offset-by script
                                          Chinnadk Level 4

                                          Hi Hasvi,

                                           

                                          Replace '=' with '==' in the 'if' condition and try.

                                           

                                          if((mypageDiff!=0) && (myTextWrap.textWrapPreferences.textWrapMode == TextWrapModes.JUMP_OBJECT_TEXT_WRAP))

                                           

                                          Regards,

                                          Chinna

                                          • 19. Re: Text wrap bottom offset-by script
                                            hasvi Level 1

                                            Hi chinna,

                                             

                                            thanx

                                             

                                            by

                                            hasvi

                                            • 20. Re: Text wrap bottom offset-by script
                                              Chinnadk Level 4

                                              Hi Hasvi,

                                               

                                              If the answer is correct then mark the answer as correct and close the thread.

                                               

                                              Regards,

                                              Chinna

                                              • 21. Re: Text wrap bottom offset-by script
                                                hasvi Level 1

                                                hi chinna sorry for this mix-up

                                                 

                                                by

                                                havi

                                                • 22. Re: Text wrap bottom offset-by script
                                                  Suzan.V Level 1

                                                  Hi all,

                                                   

                                                  are there anyway to edit your code to reverse values whatever it is between left offset and right offset as shown

                                                   

                                                  1.png