🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
7 messages
7 total messages Started by Dave_Saunders Sun, 01 Feb 2009 15:47
Detecting Permanent Overset
#1592
Author: Dave_Saunders
Date: Sun, 01 Feb 2009 15:47
7 lines
1579 bytes
For years, I've used a RunPages function to flow overset text. One thing that such a function must do is detect a permanent overset condition and stop. The test I have in the function is to test to see (a) if the frame is still overset and (b) if the frame contains no characters.

I don't know why it has taken me this long to realize that this is an inadequate test. A text frame that contains only a part of a long table also has no characters. So, if my function were used to flow a story that contained such a long table it would fail because it would erroneously decide that the story was permanently overset the moment it got to a text frame in the middle of a long table.

Has anyone else run into this? And if so, did you find a solution?

I've posted the text of my function before, but I'll put it here again in the first reply for easy reference. I think were I writing it today I'd probably break it down into more function calls but on the principle that it wasn't broke I haven't done that. Only now I realize that it is broke.
Re: Detecting Permanent Overset
#1593
Author: Dave_Saunders
Date: Sun, 01 Feb 2009 15:48
42 lines
2724 bytes
Here's the function:

function runPages(theDoc, theStory) { 
  var uRuler = theDoc.viewPreferences.rulerOrigin; 
  theDoc.viewPreferences.rulerOrigin = RulerOrigin.spreadOrigin; 
  while (theStory.textContainers[theStory.textContainers.length-1].overflows) { 
    theDoc.documentPreferences.pagesPerDocument = theDoc.documentPreferences.pagesPerDocument + 1; 
    var backPage = theDoc.pages[-1]; 
    app.activeWindow.activePage = backPage; 
    backPage.appliedMaster = theDoc.pages[-2].appliedMaster; 
    var myPbounds = backPage.bounds; 
    var myNewTF = backPage.textFrames.add(); 
    if ((backPage.name % 2 == 1) || (!theDoc.documentPreferences.facingPages)) { 
      myNewTF.geometricBounds =  
        [myPbounds[0] + backPage.marginPreferences.top,  
          myPbounds[1] + backPage.marginPreferences.left,  
          myPbounds[2] - backPage.marginPreferences.bottom,  
          myPbounds[3] - backPage.marginPreferences.right]; 
    } else { 
      myNewTF.geometricBounds =  
        [myPbounds[0] + backPage.marginPreferences.top,  
          myPbounds[1] + backPage.marginPreferences.right,  
          myPbounds[2] - backPage.marginPreferences.bottom,  
          myPbounds[3] - backPage.marginPreferences.left]; 
    } 
    myNewTF.itemLayer = theStory.textContainers[theStory.textContainers.length-1].itemLayer; 
    myNewTF.previousTextFrame = theStory.textContainers[theStory.textContainers.length-1]; 
    myNewTF.textFramePreferences.textColumnCount = backPage.marginPreferences.columnCount; 
    myNewTF.textFramePreferences.textColumnGutter = backPage.marginPreferences.columnGutter; 
    if (myNewTF.characters.length == 0){ 
      theDoc.viewPreferences.rulerOrigin = uRuler; 
      throw ("Permanently overset"); // This indicates a permanent overset condition so break out of loop 
    } 
  } 
  theDoc.viewPreferences.rulerOrigin = uRuler; 
}

And indeed, it throws the error if you try to use it to run pages for a story that consists (or includes) a table long enough that one frame in the originally overset material consists only of a part of the table.

Grrr.

Dave
Re: Detecting Permanent Overset
#1594
Author: Dave_Saunders
Date: Sun, 01 Feb 2009 15:57
9 lines
1355 bytes
What I'm hoping for is a mechanism that avoids having to check for the specific causes of permanently overset text. The fact that one of the possible causes is a row of a table that is taller than the text frame would mean having to search through the last non-overset table (the one contained by the character in the parent story of the overset frame whose index matches the index of the one insertion point in the overset frame) to see if that particular condition applies.

Now I think about it, there's another possibility for a frame with zero characters: This would happen if a paragraph had the Start on Next Even/Odd Page activated.

Hmmm.

Perhaps I should try to forget all this and return to my ignorance is bliss state.

Dave
Re: Detecting Permanent Overset
#1647
Author: Harbs
Date: Sun, 01 Feb 2009 19:09
23 lines
1450 bytes
Hi Dave,

Yes. I've dealt with this.

There's a few of problems here:

1) Next odd/even page keeps options. You can get an empty frame because 
of that. I require the last two page frames to be empty to make it 
permanently overset.
2) Continued tables (like you said).
3) Continued footnotes. The text frame will likewise have no characters 
if a footnote continues and there's no main text. (Yes. It can happen.)

If have functions to check for all of these. I'll be happy to send them 
to you if you write to me on the private...

What we really should have is properties to identify continued table 
cells/rows and continued footnote text. I've been meaning to write this 
up as a feature request for some time now...

-- 
Harbs
http://www.in-tools.com
Re: Detecting Permanent Overset
#1648
Author: Dave_Saunders
Date: Sun, 01 Feb 2009 19:22
7 lines
878 bytes
Hi Harbs,

Thanks for the offer. I guess I was just trying to confirm that I wasn't missing something obvious. For now, I'll live with what I have -- the two-in-a-row test is a good one, though.

You are clearly much more into footnotes than I've ever been!

Dave
Re: Detecting Permanent Overset
#1649
Author: Harbs
Date: Sun, 01 Feb 2009 20:20
35 lines
1858 bytes
Dave_Saunders@adobeforums.com wrote:
> You are clearly much more into footnotes than I've ever been!
>   

Probably, but I could say the same thing regarding you and tables! ;)

Here's the basic idea for getting empty frames (as you can see, my 
functions all rely upon each other):

function IsEmptyTextFrame(textFrame){
    if(textFrame.characters.length>0){return false}
    if(HasTables (textFrame)){return false}
    if(HasFootnotes (textFrame)){return false}
    return true;
    }

function HasFootnotes(textFrame){
    if(textFrame.footnotes.length>0){return true}
    var footnote = GetLastPlacedFootnote(textFrame.parentStory);
    if(! footnote){return false}
    var footnoteFrames = AsArray(footnote.parentTextFrames);
    if(GetItemIndex(footnoteFrames,textFrame)!=null){return true}
    return false;
    }
//**********************************
function HasTables(textFrame){
    if(textFrame.tables.length>0){return true}
    if(textFrame.lines.length==0){return false}
    if(textFrame.lines[0].characters.length==0){return true}
    return false;
    }

-- 
Harbs
http://www.in-tools.com
Re: Detecting Permanent Overset
#1650
Author: Dave_Saunders
Date: Sun, 01 Feb 2009 21:24
3 lines
635 bytes
Very nice. Thanks.

Dave
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads