Copy link to clipboard
Copied
I'm using script labels to find text boxes of a certain label and get their contents. Sometimes I don't get the full contents back. Is there anything I should be checking to find my error? This is the js I'm using:
var myDoc= app.activeDocument;
var myPageItems = myDoc.allPageItems;
for (var i =0; i<myPageItems.length; i++)
{
if(myPageItems.label == "rug details colors 1")
{
var myOverFlowFrame = myPageItems;
if(myOverFlowFrame.overflows==true)
{
var fullText = myOverFlowFrame.contents + '';
alert(fullText);
}
}
}
I don't have very much experience scripting against InDesign and would appreciate any help I could get. Is there a better way than .contents to get the text in a text box? Is there an obvious reason why it would fail to retrieve all of the text in some cases?
Message was edited by: rockymcclamrock (removed irrelevant code)
Hi
You can get full text using Contents of ParentStory of TextFrame,
var fullText = myOverFlowFrame.parentStory.contents + '';
thank you
Copy link to clipboard
Copied
The above script should give you the full contents of and only of the textFrames that overflow and not of the parts of stories that are overflown and not in the textFrame and also not the contents of textFrames that do not overflow.
In whcih case is it not alert the full contents that you want it to?
Copy link to clipboard
Copied
Yes, I did a poor job of asking my question initially.
I have two strings in each text frame. If they are wider than the text frame then they wrap down to the next line. The problem seems to occur when the second string is completely pushed down out of the visible area of the text frame i.e. it is all overset. I want to be able to get the full contents of the frame (including overflow), split the contents back into the two strings, trim an item from each string, then replace the contents of the text frame with the new strings. But when the second string is completely overset it is not returned as part of the contents of the text frame. How do I get the contents of the text frame that is overflown?
Copy link to clipboard
Copied
Hi
You can get full text using Contents of ParentStory of TextFrame,
var fullText = myOverFlowFrame.parentStory.contents + '';
thank you
Copy link to clipboard
Copied
Thanks, that did it. I had a really silly workaround where I temporarily increased the text box size, got the contents, and resized it to its original size. This is much better!