• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CS6 javascript - textBox.contents doesn't return full text

Guest
Feb 18, 2014 Feb 18, 2014

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)

TOPICS
Scripting

Views

742

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Feb 18, 2014 Feb 18, 2014

Hi

You can get full text using Contents of ParentStory of TextFrame,

var fullText = myOverFlowFrame.parentStory.contents + '';    

thank you

Votes

Translate

Translate
Guru ,
Feb 18, 2014 Feb 18, 2014

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 18, 2014 Feb 18, 2014

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 18, 2014 Feb 18, 2014

Copy link to clipboard

Copied

Hi

You can get full text using Contents of ParentStory of TextFrame,

var fullText = myOverFlowFrame.parentStory.contents + '';    

thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 18, 2014 Feb 18, 2014

Copy link to clipboard

Copied

LATEST

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines