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

illustrator javascript for "Identify the overset text in all text frames and reduce the font size" below are the script are identify the overset on selected text frame

Community Beginner ,
Sep 25, 2017 Sep 25, 2017

i want to identify the overset text in all text frames and reduce the font size for all overset text frames.

But the script only run on selected text frame.

#target illustrator

test();

function test(){

var doc = app.activeDocument;

var sel = doc.selection[0];

var contents = sel.contents;

for(var i = 0; i < sel.lines.length; i++){

contents = contents.replace(sel.lines.contents, "");

}

//alert(contents);

    reduceSizeOfOversetText(app.selection[0]); 

};

function reduceSizeOfOversetText(t) { 

        var d; 

        while ( 

            d = t.duplicate(), 

            d.name = 'temp', 

            d.convertAreaObjectToPointObject(), 

            d = t.parent.textFrames['temp'], 

            d.contents.replace(/[\x03\r]/g, '') !== t.contents.replace(/[\x03\r]/g, '') 

        )

        { 

            d.remove();

         //   alert(t.textRange.characterAttributes.size)

                if ((t.textRange.characterAttributes.size)<5.5)

            {

            alert("Text has been overflown  with point size of 5 points, please check the overflow text and fix as per SOP")

          

           

           return;

             // return false;

           //break;

           // exit()

                }

            t.textRange.characterAttributes.size -= 1;            

        } 

       d.remove();

       } 

kindly help on this.

Thanks in advance

Regards

Ashok

TOPICS
Scripting
999
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

Community Expert , Sep 25, 2017 Sep 25, 2017

Your test function check only first selection. You have to make for~ loop like below.

function test(){

  var doc = app.activeDocument;

  for (var j=0;j<doc.textFrames.length;j++){

     reduceSizeOfOversetText(doc.textFrames);

    }

  }

You can reference make loopin JavaScript.

https://www.w3schools.com/js/js_loop_for.asp

Translate
Adobe
Community Expert ,
Sep 25, 2017 Sep 25, 2017
LATEST

Your test function check only first selection. You have to make for~ loop like below.

function test(){

  var doc = app.activeDocument;

  for (var j=0;j<doc.textFrames.length;j++){

     reduceSizeOfOversetText(doc.textFrames);

    }

  }

You can reference make loopin JavaScript.

https://www.w3schools.com/js/js_loop_for.asp

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