5 Replies Latest reply on Aug 19, 2016 12:40 PM by Obi-wan Kenobi

    Applying master page in last page

    piongky

      Just a simple question, how to apply my Master Page "Last-Page" on the last page of my Document. Thanks

        • 1. Re: Applying master page in last page
          Obi-wan Kenobi Adobe Community Professional

          app.activeDocument.pages[-1].appliedMaster = app.activeDocument.masterSpreads.itemByName("Last-Page");

           

           

          1 person found this helpful
          • 2. Re: Applying master page in last page
            Skemicle Level 3

            Just for a bit of fun/practice for a larger project I'm working on I've created this:

             

             

            var masters = getMasterSpreads();

            var pages = getPages();

            var win = app.dialogs.add({name:"Apply Master Page"});

            with (win.dialogColumns.add()){

                staticTexts.add({staticLabel:"Apply Master Page Style:"});

                staticTexts.add({staticLabel:"...To:"});

            } with (win.dialogColumns.add()){

                var selectedMaster = dropdowns.add({stringList:masters, selectedIndex:0});

                var selectedPage = dropdowns.add({stringList:pages, selectedIndex:0});

            }if(win.show() == 0){exit();}

            var MASTER = masters[selectedMaster.selectedIndex];

            app.activeDocument.pages[selectedPage.selectedIndex].appliedMaster = app.activeDocument.masterSpreads.itemByName(MASTER);

            function getMasterSpreads(){

                var masters = new Array;

                for (c=0; c<app.activeDocument.masterSpreads.length;c++){

                    masters.push(app.activeDocument.masterSpreads[c].name);

                }return masters

            }function getPages(){

                var pages = new Array;

                for (c=0; c<app.activeDocument.pages.length;c++){

                    pages.push(app.activeDocument.pages[c].name);

                }return pages

            }

             

             

            Obi will like this one. Maybe.

            • 3. Re: Applying master page in last page
              Obi-wan Kenobi Adobe Community Professional

              Aha! Cool!

              Of course, I take it and immediately place it in your folder "Skemicle" in my ID Scripts Panel!!  Thanks! 

               

              (^/)

              • 4. Re: Applying master page in last page
                Skemicle Level 3

                Remove it. After i posted that script i realized it was missing something.. the ability to apply the master style to the spread that contains the selected page. Here is the script You will want version 2. =)

                 

                 

                var masters = getMasterSpreads();

                var pages = getPages();

                var spreads = getSpreads();

                var win = app.dialogs.add({name:"Apply Master Page"});

                with (win.dialogColumns.add()){

                    staticTexts.add({staticLabel:"Apply Master Page Style:"});

                    staticTexts.add({staticLabel:"...To page:"});

                } with (win.dialogColumns.add()){

                    var selectedMaster = dropdowns.add({stringList:masters, selectedIndex:0});

                    var selectedPage = dropdowns.add({stringList:pages, selectedIndex:0});

                    var wholeSpread = checkboxControls.add({staticLabel:"Apply to whole spread", checkedState:false});

                }if(win.show() == 0){exit();}

                var SPREAD = pages[Math.round(pages[selectedPage.selectedIndex] / 2 - .5)]-1;

                var PAGE = pages[selectedPage.selectedIndex]-1;

                var MASTER = masters[selectedMaster.selectedIndex];

                if(wholeSpread.checkedState == true){

                    app.activeDocument.spreads[SPREAD].appliedMaster = app.activeDocument.masterSpreads.itemByName(MASTER);

                }else app.activeDocument.pages[PAGE].appliedMaster = app.activeDocument.masterSpreads.itemByName(MASTER);

                function getMasterSpreads(){

                    var masters = new Array;

                    for (c=0; c<app.activeDocument.masterSpreads.length;c++){

                        masters.push(app.activeDocument.masterSpreads[c].name);

                    }return masters;

                }function getPages(){

                    var pages = new Array;

                    for (c=0; c<app.activeDocument.pages.length;c++){

                        pages.push(app.activeDocument.pages[c].name);

                    }return pages;

                }function getSpreads(){

                    var spreads = new Array

                    for(c=0; c<app.activeDocument.spreads.length;c++){

                        spreads.push(app.activeDocument.spreads[c].name);

                    }return spreads;

                }

                • 5. Re: Applying master page in last page
                  Obi-wan Kenobi Adobe Community Professional

                  Cool!  It rightly completes my "Master Pages" scripts collection! 

                   

                  Capture d’écran 2016-08-19 à 21.32.15.png

                  Capture d’écran 2016-08-19 à 21.25.32.png

                  Capture d’écran 2016-08-19 à 21.25.44.png

                  Capture d’écran 2016-08-19 à 21.26.02.png

                  Capture d’écran 2016-08-19 à 21.27.09.png

                   

                  Next! …