Skip to main content
agomexh
Participating Frequently
August 26, 2013
Answered

[JS][CC] How can I get the last visible character in an overflowed Text Frame?

  • August 26, 2013
  • 1 reply
  • 1556 views

Hello

I'm new in InDesign scripting in javascript. I would like to know if there is a way to get the position of the last character in a Text Frame that is overflowed? I need this because I want to calculate how many characters are hidden (overflowing text) via script.

I've searched in the forums about this but what I find is always a script for alerting if there's overset text or not.

I'd really appreciate any help!

This topic has been closed for replies.
Correct answer TᴀW

Well, let's say that myFrame is an overflowing text frame.

So, the last character in that frame would be

myFrame.characters[-1];

To calculate the number of overflowing characters, select the

overflowing text frame, and run this script:

myFrame = app.selection[0];

myParentStory = myFrame.parentStory;

alert("Number of overflowing characters is

"+myParentStory.characters.itemByRange(myFrame.characters[-1],

myParentStory.characters[-1]).length-1);

Ariel

1 reply

TᴀW
TᴀWCorrect answer
Legend
August 26, 2013

Well, let's say that myFrame is an overflowing text frame.

So, the last character in that frame would be

myFrame.characters[-1];

To calculate the number of overflowing characters, select the

overflowing text frame, and run this script:

myFrame = app.selection[0];

myParentStory = myFrame.parentStory;

alert("Number of overflowing characters is

"+myParentStory.characters.itemByRange(myFrame.characters[-1],

myParentStory.characters[-1]).length-1);

Ariel

agomexh
agomexhAuthor
Participating Frequently
August 27, 2013

It works! Thank you very much.