Copy link to clipboard
Copied
I'm trying to read the text content of all text frames in a document using ExtendScript:
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?
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.
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.
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"
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.