2 Replies Latest reply on Sep 6, 2016 1:10 AM by Loic.Aigon

    Change Object Style for an Inline Graphic placed by my script

    jlocke0625

      Hello!

       

      I'm stuck.  I'm trying to build a script that will search existing text for a filename, place an EPS image of the associated filename as an inline graphic in a text box, and then change the Yoffset and/or Object Style.  To make a long story short, I've arrived at this point based on these forums.  This script places the inline graphic correctly, but it does not change the Yoffset.  I tried to change the Yoffset command to apply a pre-existing object style, and my script simply ignores this command also.  Where am I going wrong?  Thanks.

       

      app.findGrepPreferences.findWhat = '<<.+?>>';

      var f = app.activeDocument.findGrep();

      var counter = 0;

      var name;

       

      for (i = 0; i < f.length; i++) {

           //construct filename       

           name = f[i].contents.replace (/[><]/g, '');

           var myFile = new File(myDialogResult.imagesFolder + "/" + name);

              if (myFile.exists) {

                   // place the image

                   f[i].insertionPoints[0].place (File (myDialogResult.imagesFolder + "/" + name));

                   app.activeDocument.links.itemByName(name).parent.appliedObjectStyle.anchoredObjectSetting s.anchorYoffset = -5 +"pt";

         counter++;

         }

         else {

              alert(name + " image file does not exist in the selected folder.",true);

              }

        • 1. Re: Change Object Style for an Inline Graphic placed by my script
          csm_phil Level 4

          Hi jlocke0625,

           

          I just modified your JS code. Try the below lines.

           

          app.findGrepPreferences.findWhat = '<<.+?>>';
          var f = app.activeDocument.findGrep();
          var counter = 0;
          var name;
          for (i = 0; i < f.length; i++) {
               var myFind = f[i];
               name = myFind.contents.replace (/[><]/g, '');
               var myFile = new File(myDialogResult.imagesFolder + "/" + name);
               if (myFile.exists) {
                   var myInllineImg = myFind.insertionPoints[0].place(File(myFile));
                   myFind.characters[0].allPageItems[0].graphics[0].parent.anchoredObjectSettings.anchorYoffset = -5 +"pt";
                   counter++;
                   }
               else {
                   alert(name + " image file does not exist in the selected folder.",true);
                   }
               }
          
          

           

           

          thx,
          csm_phil

          • 2. Re: Change Object Style for an Inline Graphic placed by my script
            Loic.Aigon Adobe Community Professional

            If the object is anchored as inline or above line, your anchorYoffset property edition will have no effect.

             

            Loic

            http://www.ozalto.com/