In the layout designed by Klaus, the page-timeline-indicator appears as a small slide running from page to page, by tiny increments. The animation below shows the first steps. In the full PDF, the process begins at page 1, ends at page 430, so there are 430 instances of the page item. Do you picture yourself pasting and placing by hand the same object 430 times?

Page-timeline-indicator on Ibsen Brand's ebook, design by Klaus Nordby

The power of scripting is to convert this kind of exhausting task into a simple click. Sometimes a long development is required, but this time the solution was almost obvious: the user only needs to create and position the object on the first page it shows up (initial position), and to duplicate it to the last place it shows up (final position), on the same page. Then he selects the first and the second page item, and runs the script.

Before running the script, the user creates two instances of the cursor, giving the initial and the final position

Regarding the script, we ask the user for the number of pages the object will cross. Our job is only to calculate the perfect move to apply from one page to the next, for the object to reach the expected position when instancied on the last page.

Here is the pseudo-code for the script:

var objs = [ app.selection[0] , app.selection[1] ];
// objs[0] reflects the object at its initial state
// objs[1] reflects the final state and need to
// be removed from the current page
 
var b0 = objs[0].geometricBounds; // position of obj0
var b1 = objs[1].geometricBounds; // position of obj1
 
var d = [ b1[1]-b0[1] , b1[0] - b0[0] ];
 
var pg0 = app.activeWindow.activePage;
var pgs = app.activeDocument.pages;
 
var p1 = ... /*here we will ask the user for the last page*/;
 
var p0 = pg0.documentOffset;
var n = p1 - p0; // how many steps?
 
var dx = d[0] / n;
var dy = d[1] / n;
 
for ( var i = 1 ; i <= n ; i++ )
    {
    objs[0].duplicate(pgs[p0+i] , [i*dx,i*dy]);
    }
 
objs[1].remove();
 
 

Screenshots

Initial state

Final state