Skip to main content
Inspiring
November 6, 2013
Question

How to get text justification using Action Manager?

  • November 6, 2013
  • 2 replies
  • 2429 views

Hi All,

I have been trying get several properties of a text layer using action script in Photoshop CS6 and CC. But here I encounterd an issue which is a Photoshop bug. I see that when I create a text layer using the default values and then try to get some values like the text justification, I get an exception. I had encountered a similar issue earlier and had resolved it by getting the properties using Action Manager.

How can I get the text justification, alignment, leading, tracking values using Action Manager?

Please help.

This topic has been closed for replies.

2 replies

May 20, 2016

Photoshop CS6 64Bit, How to get text justification using jsScript?

Anyone know? Now solved?

   if (currArtlayer.kind == LayerKind.TEXT ){

         var justificationType= currArtlayer.textItem.justification;//error !get nothing.

     }

I want to export the game interface code.

pixxxelschubser
Community Expert
Community Expert
November 6, 2013

We need a better description from you. Point text or textarea? Characters or words or simple lines or whole paragraphs? What output is desired? How much text layers etc. etc.

At the best - show some samples.

Otherwise - is "normal" javascript also ok for you?

Try something like this:

var aLay = app.activeDocument.activeLayer;

if(aLay.textItem && aLay.textItem.contents != "")

alert(aLay.textItem.justification);

alert("tracking: "+aLay.textItem.tracking);

if (!aLay.textItem.useAutoLeading)alert("leading: "+aLay.textItem.leading)

else alert("AutoLeading with: "+Math.round (aLay.textItem.autoLeadingAmount)+"%" );

Should also work in CS6/CC.


poortip87Author
Inspiring
November 7, 2013

Hi,

The above code that you suggested won't work on CS6 and CC if you do the following,

1. Create a text layer in a new document.

2. Change the alignment of the text.

3. Change the tracking value.

Now, if you try to get the font size, the script will give an exception.

I tried getting the font size by aLay.textItem.fontSize. It gives an undefined result.

I don't know why but it doesn't work.

Can you suggest anything else?

Inspiring
November 7, 2013

When Adobe introduced text styles they changed what was already a difficult scripting problem into a rats nest.

I think what is happing is if the text has a style override( noted by the + in the style name ) then you can't access most of the text properties using the DOM.

The Action Descriptors change radically if the style has an override. For example the justification setting is found in different in different descriptors depending on if the style has an override.

I think with enough work you should be able to get the info using Action Manager. It's on my list of things to do when I have the time.