Skip to main content
Participant
December 6, 2021
Answered

How to center text with Javascript?

  • December 6, 2021
  • 1 reply
  • 648 views

Hello all. 

 

I am trying to center align the text inside my text frame with javascript, but couldn't find much documentation.

 

I found "StrokeAlign" property in the documentation but there is no good example how to use it.

 

 

 

I found the feature inside indesign (selected with red box) but not sure how to proceed

This topic has been closed for replies.
Correct answer brian_p_dts

 

app.selection[0].justification = Justification.CENTER_ALIGN;

 

The justification property is found on Text, Word, Paragraph, ParagraphStyle, Character, Line, TextStyleRange, InsertionPoint and a few others: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Justification.html

1 reply

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
December 6, 2021

 

app.selection[0].justification = Justification.CENTER_ALIGN;

 

The justification property is found on Text, Word, Paragraph, ParagraphStyle, Character, Line, TextStyleRange, InsertionPoint and a few others: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Justification.html