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

Changing the text size of a text frame in Illustrator with JavaScript

Community Beginner ,
Sep 29, 2021 Sep 29, 2021

Hello, everyone;

I am writing a script in JavaScript to fill in information in an Illustrator proof template. I would like to reduce the text size of the contents of a text frame if it exceeds a certain number of characters, to prevent text overflow. I have been trying the .characterAttributes.size property, but it doesn't seem to do anything. Here is an example:

 

  var reducedFileName = app.activeDocument.textFrames.getByName("FileName");
  reducedFileName.contents.textRange.characterAttributes.size = 4;
 
The size of the contents of that text frame is set to 10 points, I just used 4 to see if it was working. So far, all the different iterations I have tried have failed. Can anyone suggest something to try?
Thanks!
TOPICS
Scripting
2.0K
Translate
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 1 Correct answer

Guide , Sep 29, 2021 Sep 29, 2021

 

reducedFileName.textRange.characterAttributes.size = 4;

 

I.e. take out "contents."  Contents is a string value. 

Translate
Adobe
Guide ,
Sep 29, 2021 Sep 29, 2021

 

reducedFileName.textRange.characterAttributes.size = 4;

 

I.e. take out "contents."  Contents is a string value. 

Translate
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 Beginner ,
Oct 01, 2021 Oct 01, 2021
LATEST

Thanks, femkeblanco! That worked like a charm.

Translate
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