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

Is there a way of recognising linebreaks with a Text Box

New Here ,
Nov 03, 2023 Nov 03, 2023

Hi,

I am running Illustrator 28.0 on Mac OS 13.6.1.

I am currently flowing varied text in to a text box, and wondered if there was a way in which I could identify the linesbreaks within the text box. So I would want to be able to recognise once the text is flown in the words 'the_' and 'Sat_'. Screenshot 2023-11-03 at 14.15.34.pngThe reason for this is so I can potentially identify with coding and manipulate actions when a linebreak is created.

Thanks

Steve

TOPICS
Experiment , How-to , Scripting , Type
214
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 , Nov 03, 2023 Nov 03, 2023

This should output a list of words at line breaks (but not paragraph breaks).  A text frame should be selected.

var output = "";
var paragraphs = app.selection[0].paragraphs;
for (var i = 0; i < paragraphs.length; i++) {
    var lines = paragraphs[i].lines;
    for (var j = 0; j < lines.length - 1; j++) {
        var index = lines[j].words.length - 1;
        output += lines[j].words[index].contents + "\n";
    }
}
alert(output);

 

 

 

Translate
Adobe
Guide ,
Nov 03, 2023 Nov 03, 2023

This should output a list of words at line breaks (but not paragraph breaks).  A text frame should be selected.

var output = "";
var paragraphs = app.selection[0].paragraphs;
for (var i = 0; i < paragraphs.length; i++) {
    var lines = paragraphs[i].lines;
    for (var j = 0; j < lines.length - 1; j++) {
        var index = lines[j].words.length - 1;
        output += lines[j].words[index].contents + "\n";
    }
}
alert(output);

 

 

 

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
New Here ,
Nov 03, 2023 Nov 03, 2023
LATEST

Thank you so much femkeblanco

That worked perfectly

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