Skip to main content
DesignPoint
Participant
November 23, 2011
Answered

Can you print only pages with a specific master page designation?

  • November 23, 2011
  • 1 reply
  • 2742 views

I'm laying out a fairly large technical book using InDesign CS4 and need to print proofs of pages that use a specific custom master page. Rather than scrolling through the Page window and writing down page numbers that use that specific master, i'd like to have a quick way of doing it. If anyone knows of a way to do this by either script or other means, I'd really appreciate the help. Thanks!

NOTE: Originally posted in general discussion and recommended to scripting forum.

This topic has been closed for replies.
Correct answer Jongware

Straight to the point, methinks. Extensive commenting was free, today.

// Gather Master Spread names

masterlist = app.activeDocument.masterSpreads.everyItem().name;

// Create a simple yet effective dialog

masterDialog = app.dialogs.add ({name:"Select Your Master",canCancel:true});

with (masterDialog)

{

          with (dialogColumns.add())

          {

                    with (dialogRows.add())

                    {

                              listbox1 = dropdowns.add ({stringList:masterlist, selectedIndex:0});

                    }

          }

}

// Get input

if (masterDialog.show())

{

          selectedName = masterlist[listbox1.selectedIndex];

          // Build Print string

          pages = [];

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

                    // What if there is NO master page applied?

                    //          .. then it's NULL and doesn't have a name, that's what

                    if (app.activeDocument.pages.appliedMaster != null &&

                              app.activeDocument.pages.appliedMaster.name == selectedName)

                              pages.push (app.activeDocument.pages.name);

          // Make a printable string of it

          printpages = pages.join(",");

          // Feed it to your current Print settings

          app.activeDocument.printPreferences.pageRange = printpages;

          // Show the Print dialog

          app.activeDocument.print (true);

}

1 reply

Jongware
Community Expert
JongwareCommunity ExpertCorrect answer
Community Expert
November 23, 2011

Straight to the point, methinks. Extensive commenting was free, today.

// Gather Master Spread names

masterlist = app.activeDocument.masterSpreads.everyItem().name;

// Create a simple yet effective dialog

masterDialog = app.dialogs.add ({name:"Select Your Master",canCancel:true});

with (masterDialog)

{

          with (dialogColumns.add())

          {

                    with (dialogRows.add())

                    {

                              listbox1 = dropdowns.add ({stringList:masterlist, selectedIndex:0});

                    }

          }

}

// Get input

if (masterDialog.show())

{

          selectedName = masterlist[listbox1.selectedIndex];

          // Build Print string

          pages = [];

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

                    // What if there is NO master page applied?

                    //          .. then it's NULL and doesn't have a name, that's what

                    if (app.activeDocument.pages.appliedMaster != null &&

                              app.activeDocument.pages.appliedMaster.name == selectedName)

                              pages.push (app.activeDocument.pages.name);

          // Make a printable string of it

          printpages = pages.join(",");

          // Feed it to your current Print settings

          app.activeDocument.printPreferences.pageRange = printpages;

          // Show the Print dialog

          app.activeDocument.print (true);

}

Jongware
Community Expert
Community Expert
November 23, 2011

Oh and it's a Javascript so save as "printByMaster.jsx", if you please.

DesignPoint
Participant
November 23, 2011

That worked perfectly, of course. Thanks Jongware! You rock sir.