Copy link to clipboard
Copied
Copy link to clipboard
Copied
function runPages(theDoc, theStory) {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.
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;
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I guess I started this discussion a long time ago when my name was in parentheses. Now I'm struggling with a related issue:
How to tell the difference between a row in a table where all the cells are overset and a row in the table that is overset because that part of the table hasn't hit the page yet?
Using:
myCell.insertionPoints[0].parentTextFrames
gives you an empty array in both situations.
The problem is that contrary to the discussion we had back in 2009, you simply can't tell the difference between a text frame that is populated by part of a table and another that isn't populated because the part of the table that should be there won't fit in the text frame. Everything I can think of gives the same result in all cases:
1 insertion point
1 line
0 characters (in the frame)
1 character in the line (now that's weird)
0 text columns
baselines (and other properties) not valid in the circumstances.
All I can think of is to try to compare the row number of the last non-overset row in the table. And that brings me to the issue how to tell the difference between a genuinely overset row and a row where every cell is overset?
Has anyone tackled this?
Dave
Copy link to clipboard
Copied
Hi Dave!
Just checking: I bet you already thought of checking if (a) the parent story of the table overflows, in combination with (b) the table is the last visible item in that story? I know, it's not conclusive ...
(GRRR! Table doesn't have an 'overflows' property, but Row does! Unfortunately, it doesn't appear to do what I thought ... I always get 'false', no matter what's in it or where the row is.)
Copy link to clipboard
Copied
Thanks Jongware.
I'm operating in the Typefi environment where my script gets kicked off at every page.start event. This means that the Typefi engine has prepared the next page for composition but hasn't yet done much with it. The script looks to see if there are any elements (in contrast to the main story) on the previous page that are overset. If so, it extends the element by a page.
If that results in the element no longer being overset then all is well, but if it doesn't, I just set things up so that at the next page.start, the script will just extend again by another page.
So, the challenge is to find a way of checking if the element is a table that some progress was made from one page to the next. If not, then we have the permanent overset condition I'm seeking. But the challenge is how to determine which rows are actually on the page versus overset. As long as I don't run into a row where all the cells are overset, this is fairly easy and can be quite efficient. At each run of the script, I can label the table with the row index of the last non-overset row and if that doesn't change from one run to the next, I have a permanent overset.
That's the thrust of my question.
I didn't realize that rows have an overflows property. I'll look into that.
Dave
Copy link to clipboard
Copied
Theun,
myRow.overflows is true if all cells in the row are overset.
Peter
Copy link to clipboard
Copied
Peter,
Thank you. That just might be enough information to sort this mess out. I think I might still be in a bit of trouble if the first overset row also happens to have cells that are all overset. And of course there's the really ridiculous case where the whole table has every cell overset, but I think I can ignore that possibility.
Dave
Copy link to clipboard
Copied
An update on this:
Row.overflows is also true if a row is overset, no matter the state of the cells in the row, so we're back to getting the same result whether a row is overset or all the cells in the row are overset (although, if the cells are not completely overset, you can check the parentTextFrames property of the first insertion points).
But, if the first cell in a row is vertically merged with a cell above it, attempting to get Row.overflows for that row fails with an error. Still, you can trap for that error and then ignore it because whatever state the row above is in, this row must be in the same state because of the merge.
Dave
Find more inspiration, events, and resources on the new Adobe Community
Explore Now