Detecting Text Length and Height

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

mycort

Detecting Text Length and Height

Post by mycort »

I'd like to run a code based on the length or height(Paragraphs) of a text string. Is there one for figuring out the text length or height, something like if(TextString.length > TextString.height)

I found this code for determining the canvas width or height,I'd like to have one for text string:

Code: Select all     if(myDoc.width > myDoc.height)
               {
                 Do something
                }
                else
                {
                Do something
                 } 

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Detecting Text Length and Height

Post by Mike Hale »

If you get the bounds of the text layer that will give you the width and height of the text in a ruler unit such as pixels, pts, in, etc.
mycort

Detecting Text Length and Height

Post by mycort »

you mean this code here?

Code: Select all      var x = doc.activeLayer.bounds[0]
      var y = doc.activeLayer.bounds[1]



so something like this?

Code: Select all      ( doc.activeLayer.bounds[0] > doc.activeLayer.bounds[1])
Mike Hale

Detecting Text Length and Height

Post by Mike Hale »

Code: Select allvar b = app.activeDocument.activeLayer.bounds;
var width = b[2]-b[0];
var height = b[3]-b[1];