Search code examples
javascriptadobe-indesignextendscript

Converting Document Pages to Master Pages


I want to convert active document pages to master pages. I have learned how to convert by watching this video. https://www.youtube.com/watch?v=o71TyJ1IkNE Any possible way to convert using script.

Thanks in Advance.


Solution

  • This script makes a new master based on current page:

    app.panels.item('$ID/Pages').visible = true;
    app.menuActions.itemByName("$ID/Save as Master").invoke();
    

    If you have several pages you can iterate them this way:

    app.panels.item('$ID/Pages').visible = true;
    
    var pages = app.activeDocument.pages;
    
    for (var i=0; i<pages.length; i++) {
        pages[i].select();
        app.menuActions.itemByName("$ID/Save as Master").invoke();
    }
    

    It works for spreads as well. (InDesign CC 2017)