Highlighted

Accessing contents of text path

Community Beginner ,
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?

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

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. 

 

 

TOPICS
Scripting

Views

169

Likes

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

Accessing contents of text path

Community Beginner ,
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?

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

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. 

 

 

TOPICS
Scripting

Views

170

Likes

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
Apr 07, 2020 0
Adobe Community Professional ,
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. 

 

 

Likes

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
Reply
Loading...
Apr 07, 2020 1
crishoj LATEST
Community Beginner ,
Apr 08, 2020

Copy link to clipboard

Copied

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"

Likes

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
Reply
Loading...
Apr 08, 2020 0
Advisor ,
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.

 

Likes

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
Reply
Loading...
Apr 07, 2020 1