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

Find TextFrame Empty

Guest
Feb 11, 2012 Feb 11, 2012

Hi All,

How to find whether a TextFrame is empty or not..

Thanks & Regards,

Ramya A

TOPICS
Scripting
1.1K
Translate
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
Mentor ,
Feb 11, 2012 Feb 11, 2012

Hi,

what exactly you are going to do with found empty text frame?

well, while waiting for REAL scripters to come...

literally, this JS code finds and selects first occurence of such item in a document:

var myStories = app.activeDocument.stories.everyItem().getElements();

for (i = myStories.length - 1; i >= 0; i--){

    var myTextFrames = myStories.textContainers;

    for (j = myTextFrames.length - 1; j >= 0; j--)    {

        if (myTextFrames.contents == ""){

            myTextFrames.select();

        }

    }

}

Translate
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
Community Expert ,
Feb 11, 2012 Feb 11, 2012

@winterm – unfortunatly it's not that easy…

It depends how you define "empty".

Is a text frame empty, if it shows no content, but

myTextFrame.overflows

is true? Technically it's empty, but you can wisely decide not to put in the same category with text frames that are "empty" and do not overflow. In that case your contents test will give a false positive.


Even more important is the case of a table that is threaded to a few text frames.
For the first text frame that holds the start of the table your test is fine, but for all other text frames that hold parts of the table you'll get false positives.

To test against this case is a really tough task…

I have no easy answer in this case, just a  method that match geometric properties of cells with the text frame singled out on an otherwise empty layer.

Uwe

Translate
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
Community Expert ,
Feb 11, 2012 Feb 11, 2012

Ok. After thinking a bit about the case with tables in threaded text frames there is a simple method to see, if the text frame is realy empty:
Just duplicate the text frame and run a test on the duplicate as well. If it is holding a table now, its contents.length property is not "0" any more.

Uwe

Translate
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
Mentor ,
Feb 11, 2012 Feb 11, 2012
LATEST

@Uwe - oh yes, you're right, it's not that easy...

I personally use 2 or 3 different scripts in different projects just to manage those "empty text frames"... Step by step, trying not to loose control. Yeah, they have many faces, especially in careless designers projects.

you see, OP question itself is not clear enough...

instead of asking back more questions, I made an attempt just to give a very basic, simple answer.

Code I posted just finds and selects first "empty frame", and it's up to user decide is it really "empty" and what to do with it...  Script won't do the whole job for you in seconds, but it won't do any harm either.

It's just a decent starting point, I think.

To go further, one must know, what exactly he expects to find and what to do with it.

And then, maybe, he'll need a little help from REAL scripter (it's not me, but I know YOU are )

Translate
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