Skip navigation
Currently Being Moderated

textItem justification no additional information available

Jun 18, 2012 6:39 PM

When I use this code

 

textLayer.textItem.justification

 

It shows some error:

 

Error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop

 

Why in some file is ok , in some file is failed?

 
Replies
  • JJMack
    3,401 posts
    Jan 9, 2006
    Currently Being Moderated
    Jun 18, 2012 8:28 PM   in reply to michael.shen

    Post the code not just textLayer.textItem.justification by itself that would generate something like textLayer is undefined...

     
    |
    Mark as:
  • JJMack
    3,401 posts
    Jan 9, 2006
    Currently Being Moderated
    Jun 19, 2012 3:50 AM   in reply to michael.shen

    Are all layers in the Text LayerSet text layers, the contain text and what version of Photoshop are you using?

     
    |
    Mark as:
  • JJMack
    3,401 posts
    Jan 9, 2006
    Currently Being Moderated
    Jun 19, 2012 2:05 PM   in reply to michael.shen

    I downloaded the PSD four of the text layers fail with that message in CS6, CS5 and CS2.  I have none of those two fonts on my machine. One of the layer that works has the same font as the four that fail. Have no idea the layers that fail are named "Event", "AT 2 P.M.", "Address and RSVP" and "Host"

     

    If I double click on these layers text layers to update the text the just click on the justerfy to the right the to the align to the left and commit them all is well???

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 12:16 PM   in reply to michael.shen

    The file only contains pointtext text layers so there is no justification. Any values you are getting are spurious and missleading.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 1:10 PM   in reply to Paul Riggott

    Sorry Paul, but Justification.CENTER, Justification.LEFT, and Justification.RIGHT work with point text. It's the several justified enum that only work( as expected ) with pargraph text.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 1:36 PM   in reply to Michael L Hale

    Thanks for that Mike, I was under the impression that textItem.position is where the text started in pointtext makeing justification irrelevant?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 1:51 PM   in reply to Paul Riggott

    It's my understanding that the textItem.position does sort of position the text but the text itself can be aglinged to the left, center, or right of that point.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 2:05 PM   in reply to Michael L Hale

    Doesn't make any difference for me Mike, textItem.position is always the same and the text does start at that position. I must be missing something?

     

     

    //#target photoshop
    var FontName = "Arial"; 
    var FontSize = 14;
    var black = new SolidColor(); 
    black.rgb.hexValue = '000000'; 
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    app.documents.add(600,400,72,"Justification Example");
    var newTextLayer = activeDocument.artLayers.add(); 
    newTextLayer.kind = LayerKind.TEXT; 
    newTextLayer.textItem.kind = TextType.POINTTEXT
    newTextLayer.textItem.color = black; 
    newTextLayer.textItem.font = FontName;
    newTextLayer.textItem.size = FontSize; 
    newTextLayer.textItem.contents = "The quick brown fox jumps over the lazy dog!";
    newTextLayer.textItem.position = Array(20, 20); 
    newTextLayer.textItem.justification=Justification.CENTERJUSTIFIED; 
    $.writeln(newTextLayer.textItem.position);
    app.documents.add(600,400,72,"Justification Example");
    var newTextLayer = activeDocument.artLayers.add(); 
    newTextLayer.kind = LayerKind.TEXT; 
    newTextLayer.textItem.kind = TextType.POINTTEXT
    newTextLayer.textItem.color = black; 
    newTextLayer.textItem.font = FontName;
    newTextLayer.textItem.size = FontSize; 
    newTextLayer.textItem.contents = "The quick brown fox jumps over the lazy dog!";
    newTextLayer.textItem.position = Array(20, 20); 
    newTextLayer.textItem.justification=Justification.LEFTJUSTIFIED; 
    $.writeln(newTextLayer.textItem.position);
    app.documents.add(600,400,72,"Justification Example");
    var newTextLayer = activeDocument.artLayers.add(); 
    newTextLayer.kind = LayerKind.TEXT; 
    newTextLayer.textItem.kind = TextType.POINTTEXT
    newTextLayer.textItem.color = black; 
    newTextLayer.textItem.font = FontName;
    newTextLayer.textItem.size = FontSize; 
    newTextLayer.textItem.contents = "The quick brown fox jumps over the lazy dog!";
    newTextLayer.textItem.position = Array(20, 20); 
    newTextLayer.textItem.justification=Justification.RIGHTJUSTIFIED; 
    $.writeln(newTextLayer.textItem.position);
    
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 2:13 PM   in reply to Michael L Hale

    I have not tested but would expect to see what Mike has suggested… For point text I would expect position to be the underlying path anchor like AI…? Justification of the type can offset based on that…

     

    Screen shot 2012-06-21 at 22.05.30.png

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 2:16 PM   in reply to Muppet Mark

    It doesn't work like that for me Mark, see what you get with the above code.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 2:25 PM   in reply to Paul Riggott

    I will give it a go Paul…

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 2:55 PM   in reply to Muppet Mark

    Paul… knock the word JUSTIFIED off each of your samples i.e. use just LEFT, RIGHT & CENTRE… This is what I meant in my previous post… What you have is JUSTIFIED type where left, right & centre are just how the last paragraph is treated… does that make sence? Sorry my painting is getting bad ( a couple of beers watching footy )

     

    Screen shot 2012-06-21 at 22.48.48.png

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 2:57 PM   in reply to Muppet Mark

    Thanks Mark that does justify to the textItem.position

    I will store that info in the 1/100000 of a grey cell

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 3:05 PM   in reply to Paul Riggott

    Paul, what I noticed is your script does NOT fail nor kick any error but if you look at the paragraph palette nothing is highlighted… Where as with my edits I get the darker icons… My guess is without a bounding box how does it JUSTIFY nothing to fit to… just one of those things…

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 5:37 PM   in reply to Muppet Mark

    Muppet Mark wrote:

     

    Paul, what I noticed is your script does NOT fail nor kick any error but if you look at the paragraph palette nothing is highlighted…

    That is why I put as expected in parentheses. The justified enums don't throw an error with point text they just don't do what one would expect. And as Mark pointed out it seems to confuse the Photoshop text tool options and the pargraph panel when you apply those via a script to a point text layer( you can't apply them in the GUI, they are greyed out ).

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 29, 2012 5:46 AM   in reply to michael.shen

    I had a look at your sample file but I also don't have the fonts used so I could not test getting the justification.

     

    I am not sure I understand your last question. I would think that the try/catch for var align = textLayer.textItem.justification.toString().replace(/Justification./, ''); is catching the same error that started this thread. I don't understand where 'exportData' comes from.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points