I'm trying to write a script in Indesign CS5 (Windows) that can measure the physical, 'rendered' length of two pieces of text of similar length (in mm etc.), calculate the average length of the two, and adjust the tracking/horizontal scale of one or both of the pieces of text so that the physical length of both texts are the same.
I need a script because this task must be done thousands of time in a long document.
I'm struggling to find a way to access the 'rendered' length of a piece of text in Javascript.
I know among the attributes of a text box is whether the text has overrun. So I could copy the text to a special text-box, and use a for loop to reduce the dimentions of the text box, 1mm at a time, until the text box overruns, thus determining the length..
I could also get the length of a rendered string using python with it's built in GUI toolkit Tkinter:
http://stackoverflow.com/questions/2922295/calculating-the-pixel-size- of-a-string-with-python
And then have an indesign script that takes some data from the python script and sets the tracking/horizontal in Indesign with some fudge factors.
Both ideas seem like real kludges.
Any other suggestions?
Many thanks
David