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

Accessing contents of text path

Community Beginner ,
Apr 07, 2020 Apr 07, 2020

Copy link to clipboard

Copied

I'm trying to read the text content of all text frames in a document using ExtendScript:

 

screenshot.png

 

The text in the vertical text frame is accessible as expected:

 

app.activeDocument.textFrames[2].contents
// Gives "#Malthe’s første skoledag"

 

 

But the contents of the text frame fitted to a path appears to be empty:

 

app.activeDocument.textFrames[0].contents
// Gives an empty string

 

 

Do texts along paths require special handling? Is there any way to read and write the contents of the text frame that's fitted to a path?

TOPICS
Scripting

Views

499

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 1 Correct answer

Community Expert , Apr 07, 2020 Apr 07, 2020

Yes, TextPaths are their own objects. You can access TextContainers through a Story object like so: 

 

 

var cons = app.activeDocument.stories.everyItem().textContainers;
for (var i = 0; i < cons.length; i++) {
    for (var j = 0; j < cons[i].length; j++) {
        $.writeln(cons[i][j].contents);
    }
}

 


Pretty sure that will hit every text frame and path in a document. I don't have much experience scripting Paths. Others might have better solutions for you. 

 

 

Votes

Translate

Translate
Community Expert ,
Apr 07, 2020 Apr 07, 2020

Copy link to clipboard

Copied

Yes, TextPaths are their own objects. You can access TextContainers through a Story object like so: 

 

 

var cons = app.activeDocument.stories.everyItem().textContainers;
for (var i = 0; i < cons.length; i++) {
    for (var j = 0; j < cons[i].length; j++) {
        $.writeln(cons[i][j].contents);
    }
}

 


Pretty sure that will hit every text frame and path in a document. I don't have much experience scripting Paths. Others might have better solutions for you. 

 

 

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 Beginner ,
Apr 08, 2020 Apr 08, 2020

Copy link to clipboard

Copied

LATEST

Thank you!

 

I was able to retrieve the text content of the TextFrame:

 

app.activeDocument.textFrames[0].textPaths[0].contents
# Gives "#Malthe’s første skoledag"

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
Guide ,
Apr 07, 2020 Apr 07, 2020

Copy link to clipboard

Copied

Hi,

 

When handling paths ( in my application ) I use p.lines[0]. Probably not as robust as looking at the textContainers. ( brianp311 )

 

P.

 

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