10 Replies Latest reply on Jul 30, 2018 4:48 AM by Phil_Selman

    Text Wrap Only Applying to TextWrapModes.CONTOUR via JS

    Phil_Selman

      Here's a weird one. I'm trying to write a script that applies TextWrapSideOptions.LARGEST_AREA to every graphic in my document. However, my script only applies this to graphics already set to TextWrapModes.CONTOUR. I have no idea why, as TextWrapModes aren't specified anywhere in this script. Here's what I've got.

       

      for (i=0; i<app.activeDocument.allGraphics.length; i++)

      {

          wrapIt (app.activeDocument.allGraphics[i]);

      }

       

      function wrapIt (img)

      {

          img.textWrapPreferences.textWrapSide = TextWrapSideOptions.LARGEST_AREA;

      }

       

      Anyone have any insights for me? The alternative is either doing this manually or convincing my layout designers to properly format images. I'll let you guess which is more likely to happen.

       

      Thanks!

        • 1. Re: Text Wrap Only Applying to TextWrapModes.CONTOUR via JS
          Laubender Adobe Community Professional & MVP

          Hi Phil,

          see into all read/write properties for textWrapPreferences.

          If textWrapPreferences.textWrapMode is set to TextWrapModes.NONE you see no effect of textWrapSide.

           

          Something like that should work:

           

          var doc = app.documents[0];
          var allGraphics = doc.allGraphics;
          var allGraphicsLength = allGraphics.length;
          
          for ( n=0; n<allGraphicsLength; n++)
          {
          
              allGraphics[n].textWrapPreferences.properties =
              {
                  textWrapMode : TextWrapModes.CONTOUR ,
                  textWrapSide : TextWrapSideOptions.LARGEST_AREA ,
                  textWrapOffset : NothingEnum.NOTHING ,
                  applyToMasterPageOnly : false
              };
          
          };
          

           

          Regards,
          Uwe

          • 2. Re: Text Wrap Only Applying to TextWrapModes.CONTOUR via JS
            Phil_Selman Level 1

            Hey there, thanks for the quick response.

             

            Unfortunately, this doesn't quite address or solve my problem. My issue isn't with converting all graphics to "TextWrapModes.CONTOUR" and "TextWrapSideOptions.LARGEST_AREA." In fact, I could already do that by simply adding "

            img.textWrapPreferences.textWrapMode = TextWrapModes.CONTOUR;" to my original function. What I'm trying to do is to set every graphic to "TextWrapSideOptions.LARGEST_AREA: regardless of its textWrapModes setting.

             

            On a side note, I found that if I substitute a different TextWrapModes setting (e.g., substituting "TextWrapModes.BOUNDING_BOX_TEXT_WRAP" for TextWrapModes.CONTOUR"), I always get the same result: all graphics change their TextWrapModes setting to "NONE." This is true for both my original script and your. Even though my goal isn't to change ant TextWrapModes setting, I find this extremely frustrating because I can't find any reason this should happen.

            • 3. Re: Text Wrap Only Applying to TextWrapModes.CONTOUR via JS
              Laubender Adobe Community Professional & MVP

              Hi Phil,

              did you check if you can achieve what you want using InDesign without scripting?
              And if so couldn't you check the properties and the values with text wrap then?

               

              Regards,
              Uwe

              • 4. Re: Text Wrap Only Applying to TextWrapModes.CONTOUR via JS
                Laubender Adobe Community Professional & MVP

                Hi Phil,
                I cannot see why this should not work:

                 

                var doc = app.documents[0]; 
                var allGraphics = doc.allGraphics; 
                var allGraphicsLength = allGraphics.length; 
                
                for ( n=0; n<allGraphicsLength; n++) 
                { 
                
                    allGraphics[n].textWrapPreferences.properties = 
                    { 
                      //  textWrapMode : TextWrapModes.CONTOUR , 
                        textWrapSide : TextWrapSideOptions.LARGEST_AREA , 
                        textWrapOffset : NothingEnum.NOTHING , 
                        applyToMasterPageOnly : false 
                    }; 
                
                };
                

                 

                Just tested with some placed graphics with different values for text wrap mode on InDesign CC 2018.1 on Windows 10.

                Can you make up a case where it is not working and show it using some screenshots?

                 

                Before > After > How it should be

                 

                Regards,
                Uwe

                • 5. Re: Text Wrap Only Applying to TextWrapModes.CONTOUR via JS
                  Phil_Selman Level 1

                  Oh good—I'm not crazy. Yeah, that should work. The fact that it doesn't makes this most likely not a scripting issue.

                   

                  To elaborate, I decided to take a different approach and use Find/Change Object commands the way I've successfully manipulated grep quarries via JS. No dice. In fact, when attempting to manually search for any graphic frames set to wrap to both side, it came up empty every time. This is starting to look like a bug to me. I suppose this is a matter for tech support to sort out.

                   

                  As a novice, I really appreciate your help on this, if only to reassure me that I wasn't doing anything too far off. Thank you!

                  • 6. Re: Text Wrap Only Applying to TextWrapModes.CONTOUR via JS
                    Laubender Adobe Community Professional & MVP

                    Hi Phil,

                    oh. Please check if it makes a difference if you are addressing the placed graphic and/or the frame holding the placed graphic.

                    The frame holding the placed graphic is the parent of the graphic.

                     

                    Reards,
                    Uwe

                    • 7. Re: Text Wrap Only Applying to TextWrapModes.CONTOUR via JS
                      Laubender Adobe Community Professional & MVP

                      And I really like to see a case where the script snippet above will not work.

                      You can use a download service like Dropbox and add a link here.

                      Use InDesign's package command and zip the packaged document with the Links folder.

                       

                      Regards,
                      Uwe

                      • 8. Re: Text Wrap Only Applying to TextWrapModes.CONTOUR via JS
                        Phil_Selman Level 1

                        Good idea. I just tried that, and it doesn't seem to make a difference. Here's a screenshot of me attempting to do this manually via the Find/Change Object module.

                         

                        Screen Shot 2018-07-30 at 7.28.29 AM.png

                         

                        Forgive my silliness.

                        • 9. Re: Text Wrap Only Applying to TextWrapModes.CONTOUR via JS
                          Laubender Adobe Community Professional & MVP

                          My, my…

                          I think Object Find/Change is a bag of bugs.

                          Better work around this and work with the allPageItems array of the document and filter that for known property/value pairs.

                           

                          Regards,
                          Uwe

                          • 10. Re: Text Wrap Only Applying to TextWrapModes.CONTOUR via JS
                            Phil_Selman Level 1

                            Yeah... I was starting to suspect that could be the case. I guess I'm going to have to roll up my sleeves and get a bit deeper into scripting to sort this out. I'll just call this inspiration to get better at scripting (assuming I can find enough spare time to do that).

                             

                            Much obliged for your time and effort,

                            —Phi