• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Vertical alignment scripting

New Here ,
Sep 21, 2021 Sep 21, 2021

Copy link to clipboard

Copied

In Illustrator we have the option to vertically align text via Area Type, which is a great addition. However, I would like to use this feature through scripting. Can anyone tell me if this is available (cannot find it in the docs) and if so, how to use it? I'd imagine it to look something like this:

 

textRef.AreaType = Align.CENTER

 

TOPICS
Scripting

Views

692

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Sep 21, 2021 Sep 21, 2021

alignment_text.png

 

I don't think this is possible in the way you want. Unfortunately, with scripts we don't have access to the alignment options for text frames.

Votes

Translate

Translate
Community Expert , Sep 22, 2021 Sep 22, 2021

Text Align Center can be recorded, so do that, then have your script run the Action (or use standalone)

Votes

Translate

Translate
Adobe
Guide ,
Sep 21, 2021 Sep 21, 2021

Copy link to clipboard

Copied

This works for both point and area text:

// select textFrame
var text1 = app.selection[0];
text1.textRange.paragraphAttributes.justification = Justification.CENTER;

 

Edit:  I misread what you wrote. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2021 Sep 21, 2021

Copy link to clipboard

Copied

alignment_text.png

 

I don't think this is possible in the way you want. Unfortunately, with scripts we don't have access to the alignment options for text frames.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2021 Sep 21, 2021

Copy link to clipboard

Copied

Is that it? 

app.selection[0].textRange.characterAttributes.alignment = StyleRunAlignmentType.center;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 22, 2021 Sep 22, 2021

Copy link to clipboard

Copied

Unfortunately this doesn't vertically align the text

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 22, 2021 Sep 22, 2021

Copy link to clipboard

Copied

LATEST

Text Align Center can be recorded, so do that, then have your script run the Action (or use standalone)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines