4 Replies Latest reply on Oct 11, 2012 3:50 AM by Bill joy

    Rectangle text Content problem

    Bill joy Level 1

      Hi All,

       

      I want to insert text in rectangle.

      After setting ContentType "Text" How insert text in rectangle?

      I am not  found content method for rectangle like TextFrame.content="indesign";

       

      var myDocument = app.documents.add();

      var myRectangle = myDocument.pages.item(0).rectangles.add();

      myRectangle.geometricBounds = ["70p", "20p", "40p", "40p"];

      myRectangle.contentType=(1952412773);//for text 1952412773,

      //myRectangle.place(File("/C/version.jpg")); //for place image

       

       

      How add text in rectangle ?

       

      Thanks in advance

        • 1. Re: Rectangle text Content problem
          TᴀW Adobe Community Professional & MVP

          I haven't tested what I'm about to say, but my gut instinct is that when

          you set the rectangle contentType to text, it turns into a textFrame.

          Then when you place a file, perhaps it turns back into a rectangle?

           

          At any rate, you can't "place" an image into a text frame, and you can't

          have text in a rectangle.

           

          Hope that points you in the right direction.

           

          Ariel

          • 2. Re: Rectangle text Content problem
            Bill joy Level 1

            Thanks for Reply

            I try this

             

            var myTextFrame=myRectangle.contentType=(1952412773);

            myTextFrame.content="Indesign";

             

            Script run sucessfully with answer  Execution finished. Result : Indesign

            But text "Indesign" is not written in Rectangle.

             

            Thanks.

            • 3. Re: Rectangle text Content problem
              Jump_Over Level 5

              Hi,

               

              To create a rectangle, change its content type and place text into - it is not a shortest way;

              you can do it easier by creating a textFrame instead of rectangle;

              but if it is your way from some reason:

               

              you have to resolve rectangle after changing content type to let InDesign know about this change.

               

              So it should be like this:

               

              var myDocument = app.documents.add();

              var myRectangle = myDocument.pages.item(0).rectangles.add();

              myRectangle.geometricBounds = ["70p", "20p", "40p", "40p"];

              myRectangle.contentType = ContentType.TEXT_TYPE;

              var myTextFrame = resolve(myRectangle.toSpecifier());

              myTextFrame.contents = "InDesign";

               

              hope...

              • 4. Re: Rectangle text Content problem
                Bill joy Level 1

                Thanks Jump_Over

                Its work sucessfully.

                 

                Thanks