4 Replies Latest reply on Jul 24, 2013 7:50 PM by Bill joy

    How place image in text frame?

    Bill joy Level 1

      Hi Experts

      I am trying to place image in text Frame.

      If Text frame is on pasteboard then image is place sucessfully.

      if Text frame start from outside the pasteboartd or exists outside the pasteboard then image not place in textframe while text is insert in textframe.

      My text frame coordinate is :

      x =  -81.74 pt

      y =  -138.275 pt

      w =  760.123 pt

      h =  1117.944 pt

       

      It start from outside the pasteboard.

       

      #target indesign

      var myDocument=app.activeDocument;

      try

      {

      var myTextFrame=myDocument.spreads.item(0).textFrames.item(0);

      //myTextFrame.contents="InDesign";

      myTextFrame.place(File("/C/temp/1.jpg"));

      }

      catch(e)

      {

          var k=0;

      }

       

      I am not understand that   text is insert in textframe but image is not place.

      when i change text frame x=10 pt and y =10 pt then this script work well.

       

      How place image in textframe which is outside the pasteboard ?

       

      Thanks.

        • 1. Re: How place image in text frame?
          Jump_Over Level 5

          Hi,

          The bad news is you cant place a new object outside the pasteboard.

          The good news is you can move it there...

           

          so:

           

          var myTextFrame=mDoc.spreads.item(0).textFrames.item(0),
          mPlace = [ myTextFrame.geometricBounds[1], myTextFrame.geometricBounds[0] ];
          
          myTextFrame.move([0,0]);
          myTextFrame.place(File("/C/temp/1.jpg"));
          myTextFrame.move(mPlace);
          

           

          Jarek

          • 2. Re: How place image in text frame?
            Bill joy Level 1

            Thanks Jump_Over for reply.

             

            It work for me.

            But I am not understand that   text is insert in text frame (while Text frame start from outside of the pasteboard )but image is not place.

             

            Thanks once again.

            • 3. Re: How place image in text frame?
              Laubender Adobe Community Professional & MVP

              @Jarek – Ok. First I had trouble recreating the situation. Perhaps I had misunderstood.

               

              Now: in  case the upper left x/y coordinates of the text frame are outside  the pasteboard an error will be thrown…

               

              So, moving the object to 0/0 would be a good approach.

              A different solution would be to expand the pasteboard so that the upper x/y coordinates of the text frame would fit on the pasteboard (perhaps the text frame is locked or part of a table cell, then you cannot move the text frame).

               

               

              @Bill – in the moment you place the image the text frame no longer is a text frame, but an ordinary rectangle (or what ever shape it had before).

               

              You can also place an image to an insertion point of the text frame (or the parent story) as an inline graphic without loosing the contents.

               

              Or you could add a rectangle to an insertion point and place the image there giving some fit attributes to the container (e.g.: myRectangle.fit(FitOptions.PROPORTIONALLY).

               

              Uwe

              • 4. Re: How place image in text frame?
                Bill joy Level 1

                Thanks  Laubender for your reply.