3 Replies Latest reply on Apr 18, 2016 12:35 PM by williamadowling

    scale a textframe



      I am trying to scale a textframe to desired dimensions with this script, but it does not work.

      The JS manual tells about some transformation matrix but apparently the way it is coded in the script is incorrect.


      var title = "Dimensions of textframe"; 

      var width = Number(Window.prompt ("width", 200, title)); 

      var height = Number(Window.prompt ("height", 800, title)); 

      var a = app.activeDocument.textFrames[0].transform(width,height,50,50);


      How to get it working?

        • 1. Re: scale a textframe
          CarlosCanto Adobe Community Professional & MVP

          correct, to use transform() you must supply a transformation matrix.


          if you just need to resize the text frame with the dimensions provided try this


          var title = "Dimensions of textframe";
          var width = Number(Window.prompt ("width", 200, title));
          var height = Number(Window.prompt ("height", 800, title));
          app.activeDocument.textFrames[0].width = width;
          app.activeDocument.textFrames[0].height = height;
          • 2. Re: scale a textframe
            sylvio33 Level 1

            Perfect! Many thanks, Carlos!

            • 3. Re: scale a textframe
              williamadowling Level 4

              Are you trying to resize a single line of text or an area type text box?


              If you're trying to modify an "area text" box, you can simply use:


              var textBox = docRef.textFrames[0]

              var inputHeight = Number(prompt("Enter Height"));

              var inputWidth = Number(prompt("Enter Width"));

              textBox.height = inputHeight;

              textBox.width = inputWidth;


              If you're trying to modify a "point type" text box, you're going to run into issues with getting the text the correct size. Due to the fact that illustrator doesn't properly measure the height of the actual text, but rather the bounding box around the text which includes an unknown and variable amount of space above, below and to each side of the text. See screenshot. Whenever you re-size a point text box, the size is measured by the bounding box, not the text itself.


              Screen Shot 2016-04-18 at 2.32.12 PM.jpg