Copy link to clipboard
Copied
I am looking to create a line in my footer that looks like the "grows" with each page of the document. So for example the first page it starts at a lenth of 1 and the second page it would be a 2 so on and so forth.
I have been able to create this by manually drawing the line and adjusting it with each page however I was wondering if anyone has ever done this with some level of automation?
It would be ideal if I had a parent page set up and ID automatically adjusted the size of the line based on the total document length and the current page number.
<Title renamed by moderator>
I can't think of any automatic - built in - way to do this.
But it's easily scriptable - either by duplicating some object from page to page and make it longer - or override object from MasterSpread and then set its length based on the page's index.
I'm not JS guy so can't give you working code.
Well, ok, "a line in the footer" doesn't have to be a footnote-separator rule. But that's how I interpreted it.
Copy link to clipboard
Copied
Clever! Though the page marker is a marker that the font doesn't see as a number. You'd have to use a text frame and use a script to place the page number (or document offset) in there. Also, you need a conversion number: page 50 in a 100-page file and page 5 in a 10-page document should get the same length bar, but won't.
Copy link to clipboard
Copied
I thought I should put my idea to the test. Here's a script, a sample document is attached.
There's one requirement: the footer lines should be named 'Progress line' on the Layers panel:
A nice enhancement would be to place a lighter-shade bar behind the progress bar so it's easier to see how much there's left to go.
(function () {
var indd = app.documents[0];
var pages = indd.pages.everyItem().getElements();
var rule;
var gb;
var step;
function stepValue () {
var r = indd.masterSpreads.everyItem()
.graphicLines.everyItem().getElements();
for (var i = 0; i < r.length; i++) {
if (r[i].name === 'Progress line') {
var b = r[i].geometricBounds;
return (b[3] - b[1]) / (indd.pages.length-1);
}
}
return null;
}
//--------------------------------------
// If there's a rule on the page, return it.
// Otherwise, try to override one.
function getRule (page) {
var r = page.graphicLines.item ('Progress line');
if (r.isValid) {
return r;
}
var m = page.masterPageItems;
for (var i = 0; i < m.length; i++) {
if (m[i].name === 'Progress line') {
return m[i].override (page);
}
}
return null;
}
//==================================================
step = stepValue();
if (!stepValue) {
alert ('The document lacks a rule named "Progress line"');
exit();
}
for (var i = 0; i < pages.length; i++) {
rule = getRule (pages[i]);
if (rule) {
gb = rule.geometricBounds;
rule.geometricBounds = [gb[0], gb[1], gb[2], gb[1]+(i*step)];
}
}
}());