Skip to main content
Inspiring
November 6, 2013
Question

How to get text justification using Action Manager?

  • November 6, 2013
  • 2 replies
  • 2421 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
Adobe 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?

pixxxelschubser
Adobe Expert
November 7, 2013

poortip87 schrieb:

… 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?

Is this the right code in CS6/CC ???

In other versions I use: aLay.textItem.size

And I tested my code at work with CS6 (without paragraph style) today. Changed the justification and so on. It works for me.

You know, that you should read some properties like justification only line for line to get the correct result? Because of you can get every line a different justification.