Skip navigation
Currently Being Moderated

How to detect a completely empty text frame (incl. no continued footnotes, no continued tables)

Aug 26, 2012 7:18 AM

Hi,

 

This is a problem I've ignored for a long time...

 

Say I have a script that deletes all empty text frames. It's easy to

find an empty text frame with something like:

 

if (myFrame.characters.length < 1) -- the frame is empty!

 

But ... this doesn't work for 2 cases (at least, that I can think of):

(1) If the text frame contains the second half of a footnote that is

continued from a previous text frame(s); (2) if the text frame contains

the second half of a table that is continued from a previous text frame(s).

 

In both these cases (where the frame ONLY contains the second half of a

table or footnote), the simple way of checking whether the frame is

empty (as I showed above) returns a false positive -- the character

length of the frame is 0, but the frame is NOT empty.

 

Any idea how to solve this?

 

Thanks,

Ariel

 

 
Replies
  • Currently Being Moderated
    Aug 26, 2012 8:28 AM   in reply to [Ariel]

    Especially with continuation tables, this is tricky and messy, and CS5+ require different approaches than earlier versions. If you are deleting frames from the end of the textContainers array, maybe you can delete frames until the last frame oversets. If it does, put the frame back.

     

    It's probably easier to unthread the last frame. If the previous frame does not overset, delete the last frame; if it does overset, restore the thread.

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 26, 2012 11:02 AM   in reply to [Ariel]

    Footnote.textFrames is the collection of all text frames that are anchored/inline to the footnote.

     

    This empty frame thing is a real challenge. If you have a table that spans more than two frames, the intermediate frames that only contain part of a table are a pain to identify (I guess the same is true of partial footnotes, although such long footnotes don't come up so often as long tables do.

     

    With CS5+, you can get

     

    myTable.storyOffset.paragraphs[0].lines.everyItem().parentTextFrames[0 ]

     

    I believe that will get you an array of the text frames visited by the paragraph holding the table.

     

    Hmm. I wonder what happens if you use:

     

    myTable.storyOffset.parentStory.lines.everyItem().parentTextFrames[0]

     

    That will probably run rather slowly, but it should give you a highly repetitive array of all the text frames visited by the story.

     

    Doesn't solve the footnotes issue though.

     

    Dave

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 26, 2012 12:21 PM   in reply to Dave Saunders

    Can"t Logical Reasoning solve this?

     

    A text frame is empty if (a) it is not connected to a next or previous text frame, and (b) it has no contents. Safe to delete.

     

    If (b) is true but (a) not, skip this one and go to the last frame in this thread. If it *seems* to be empty, delete it and check the *previous* frame for Overset Text. If not .. it was empty after all! Then continue with that frame.

     

    Don't loop over text frame, loop over Stories, so you'll visit each frame only once.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 26, 2012 1:37 PM   in reply to [Jongware]

    What does "it has no contents" mean? Contents of ""?

     

    If you have:

     

    Text

    Long Table

    Text

    Empty Frames at end

     

    Then the overset test will work only if you cycle backwards through the text containers of the story. Must get rid of those at the end before looking at those in the middle.

     

    A text frame in the middle can be empty because of a text wrap. I guess it's a question of whether or not you want to delete those too. If not, then work from the end of a story until you find a frame that is not empty and then, almost by definition, all the previous frames are not empty -- although even in this scenario you could have a very small frame that is empty because there isn't space in it for even one character.

     

    Dave

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 27, 2012 12:23 AM   in reply to Dave Saunders

    @Dave – and there is another case we have to consider:

     

    An empty text frame that is not meant to be a text frame at all. E.g. a rectangle, that the user transformed inadvertantly to a text frame by clicking into it with the text tool. If you remove one of those you could wreck the layout…

     

    Uwe

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)