Reply To: Script to duplicate page/spread after current

#63939

It's suprisingly easy. The scripting interface knows what 'layout window' you are looking at (in case you have several windows and/or documents opened), and it knows what page or spread is selected inside that window. Both a Spread and a Page have a “duplicate” method, which does exactly what it says — always a nice surprise –, and you also can indicate where the duplicate should be placed.

This one-liner will duplicate the current spread:

app.layoutWindows[0].activeSpread.duplicate (LocationOptions.AFTER, app.layoutWindows[0].activeSpread);

and this one the current page:

app.layoutWindows[0].activePage.duplicate (LocationOptions.AFTER, app.layoutWindows[0].activePage);

Note that in the latter case it's slightly ambiguous what the 'current page' is when you are viewing a double spread. When both pages are selected in the Pages panel, the script uses the leftmost page. To be sure what page gets duplicated, use Shift+PgUp and Shift+PgDn to zoom in on the specific page you want to duplicate.

Best of all: if you need this often, well, you can bind shortcut keys to scripts.

This article was last modified on January 14, 2013

Comments (0)

Loading comments...