Reputation: 11401
I am building an InDesign panel with ExtendScript which finds text and shows it to the user. To do this, I use the showText()
method of the Character object. The problem is that sometimes the text I'm looking for doesn't appear because, even though the method does show the right page at the right place, the text has overflown and is not visible.
Is there a way to check if the text is visible or not? Ideally, I would like to be able to fall back on the story editor if the text cannot be seen as-is...
Upvotes: 1
Views: 764
Reputation: 666
To check the situation for an individual character, see the parentTextFrames property, it returns an array with 0 or 1 frames. In rare cases of insertion points whose left side is in one frame while the right side is in the following, you get two frames.
app.selection[0].characters.item(0).parentTextFrames.length
You can also compare the index of your character against the last index in the last text container of the story, e.g.
app.selection[0].parentStory.textContainers.pop().characters.lastItem().index
Of course you should first see whether there is overflow at all ...
app.selection[0].parentStory.overflows
Upvotes: 4
Reputation: 506
You may call the baseline property for the text in a try/catch statement. If text is visible, baseline will return a value, otherwise it will raise an error.
Loic
Upvotes: 1