3 Replies Latest reply on Oct 18, 2013 12:07 AM by Sathya Rani M

    Reg. Place image in textframe

    Sathya Rani M

      HI All,

       

      I have been struggling lot to place an image near to the find text. From the below code snippet I could place the image but it is placing in anchor frame.

       

      Since the image in anchor frame, the text wrap preferences could not apply.

       

      var myFoundItems = new Array;

      var mydoc = app.activeDocument;

      app.findTextPreferences = null;

      app.findTextPreferences.findWhat = "<F1><\F2>";

      myFoundItems = app.activeDocument.findText();

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

      {

          var myFile = File(myFilteredimages[i]); // Array contains images - myFilteredimages[i]

          if(myFile.exists)

          {

              myFoundItems[i].place(myFile);

          }

      }

       

      I do not want to place the image in anchor frame, Please help me out in this.

      Thank a lot.

       

      Regards,

      Sathya Rani M

        • 2. Re: Reg. Place image in textframe
          Laubender Adobe Community Professional & MVP

          @Sathya – you wrote:

          I do not want to place the image in anchor frame

           

          What do you exactly want then?


          Placing the image at the found text position independent of the text frame? Just above the text having set the stacking order from background to foreground: 1. text frame, 2. image? Maybe obscuring the text?

           

          Then I would add a tiny rectangle to the found text insertion point, reading out its position, remove the rectangle and move the placed image to the recorded position.

           

          In regular text frames (not rotated ones) you could also read out the properties "horizontalOffset", "baseline" and "baselineShift" to calculate the x/y coordinates for the image to be placed.

           

          For getting the right page to place the image you could use the "parentTextFrames[0].parentPage" of the found insertionPoint.

           

          Uwe

          • 3. Re: Reg. Place image in textframe
            Sathya Rani M Level 1

            Thank you for the reply. I have placed the image to the found textframe parent.

             

            Please see the piece of code below.

             

            for(k = 0; k < myTagnames.length; k++)

            {

                app.findTextPreferences = null;

                app.findTextPreferences.findWhat = myTagnames[k];

                myFoundItems = app.activeDocument.findText();

             

             

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

                {

                    progress.value = i+1;

                    var myFile = File(myFilteredimages[i]);

                    myFrame = myFoundItems[i].parentTextFrames[0];

                    if(myFile.exists)

                    {

                        app.select(myFrame.parent);

                        PlaceIntoFrame(myFrame,myFile);

                        continue;

                    }

                }

            }

             

             

            function PlaceIntoFrame(myFrame, myFile)

            {

                myFrame.parent.place(myFile);

            }

             

            It works fine.

             

            Regards,

            Sathya Rani M