This content has been marked as final. Show 10 replies
You can't easily tell ID to pause a script. However, I think it is possible to check for more than 4 blank lines at the bottom of a textframe.
(Just thinking out loud.)
TextFrame has a
property. Therefore, "myTextFrame.lines.length" holds the number of lines. If your leading is the same all over the page and you don't have any space above or below paragraphs, you're done: your typical page can hold (say) 40 lines, myTextFrame.lines.length is 30, so there are 10 blank lines. Unlikely, but a good start, innit? ;-)
If you know the number of lines in a text frame, you can access the properties of the
line, for example, "endBaseline" ("Vertical offset of the end of the text"). Now you have a vertical position with "myTextFrame.lines[myTextFrame.lines.length-1].endBaseline". Compare this with the bottommost possible position, and you know how much
you have at the bottom. Then your script can decide if and how to pull up some text from the next page.
Which (while typing) made me think: how are you going to get more lines using word spacing? You must mean
spacing instead, and that means your script (or, in the case of manually tinkering, you) has to go over the lines in that particular text frame and adjust line spacing and/or paragraph spacing until you get the required space for a few lines more.
What if the paragraph on the next page cannot be run in, because it's a heading (with accompanying white space above and below, and has to tag along a few lines of text as well) or because it's a three-line paragraph (which, under regular circumstances, may not be broken into 2-then-1 line or 1-then-2 lines)?
Actually since all our books are full justified I can use word spacing to force a paragraph longer or shorter to make it wrap or pull up. We also only have one possible font size or leading and three different paragraph styles but I have already figured out how to make avoid trouble with the paragraph styles. honestly the standards we have doesn't leave much room for creativity but does open the door to automation. Thanks for the hint I'll give it a shot and see if it works.
>since all our books are full justified I can use word spacing to force a paragraph longer or shorter to make it wrap or pull up
Yeah, I have a script that does just that -- decrease tracking until the paragraph is just a single line shorter. I have to manually select candidates, though. I can try to write a version that works on an entire page and selects the best possible candidate by itself :-) (And if that works, let it loose on an entire document.)
Regarding my last question/pondering: perhaps the script could run in one line, then check if it made things better, i.e., if the frame indeed now contains more lines than before. If not, it could revert its doings and continue with the next page.
CS4 isn't out yet, but it is relevant to mention that its paragraph composer is far less likely to create short last lines in left justified paragraphs than are any of its predecessors.
Really? Thats great, I have noticed CS4 seems to be promising a great deal. does anyone know if CS3 scripts will be directly compatible with CS4? Jongware I would love to take a look at that tracking script your talking about I bet that could be a life saver.
Here it is:
if (app.selection.constructor.name == "InsertionPoint")
var l = app.selection.paragraphs.lines.length;
if (l < 2)
alert ("Just 1 line -- can't run in :-(");
// alert ("Num lines is "+l);
var org_track = app.selection.tracking;
var track = app.selection.tracking;
// alert ("Tracking is "+track);
while (app.selection.paragraphs.lines.length == l)
app.selection.paragraphs.tracking = track;
if (app.selection.paragraphs.lines.length == l)
app.selection.paragraphs.tracking = org_track;
if (org_track - track > 10)
if (confirm ("Tracking was "+org_track+", is nu "+track+"!\nUndo?") == true)
app.selection.paragraphs.tracking = org_track;
Put the text cursor into a paragraph with (preferably) lots of lines and a short last one.
It tracks up to -10 of the original value (whatever that was) without warning. If more, you get a warning, and since you most likely don't want a tracking of more, the default is "Yes" -- simply hit Enter to undo.
It does some trickery with resetting-then-setting the new value, so if you don't like it, you only need a single Undo.
There are some changes, but not many (although, obviously, there's a lot of new stuff to support the new featres). As soon as CS4 hits the street, I'll start a "What's changed" topic.
Thanks for your help Guys I got it working!
"CS4 isn't out yet, but it is relevant to mention that its paragraph composer is far less likely to create short last lines in left justified paragraphs than are any of its predecessors."
I'm interessed to hear more about that one!
I had to deal with alot of "orphans" in a recent project. Manually correcting them was not a very practical solution because of the automation (had to redo the correction every time the document is regenerated from database). I have tried using "balance ragged lines" by exemple, but it was affecting pretty much all the text, not just the ones with one word alone on the last line...
CS4 is out now. Early in the beta cycle, I reported the CS3 propensity for having short lines at the end of justified paragraphs (not full justified of course) and the engineering team took a good look at it and realized that while the behavior didn't quite warrant being called a bug, it was the result of a weakness in the algorithm, where they were in effect applying full justify and then setting the last line to be left (or whatever) aligned.
This often results in the text on that line taking more space and that's where the short lines come from. The CS4 algorithm avoids this, keeping the last line justified as long as it fits within your settings.