3 Replies Latest reply on Jan 9, 2014 4:42 AM by Green4ever

    Master Pages - PDF

    KirstenHill123

      Hello

       

      Is there a setting to automatically PDF only the pages from one certain Master Page type?

      Ie, I would like to PDF all the pages that one Master type are attributed too but no other pages. Is this possible?

       

      Thank you in advance.

        • 1. Re: Master Pages - PDF
          Green4ever Level 3

          Hi,

           

          yes, it is possible. see the following example it may give you some idea.

           

          var myDoc = app.activeDocument;
          var myPages = myDoc.pages;
          var pageLength = myPages.length;
          var masterPageName = "A-Master";
          var myPageName, pageNoList = [];
          for (var p=0; p<pageLength; p++){
              myPageName = myPages[p].appliedMaster.name;
              if (myPageName == masterPageName){
                  pageNoList.push(myPages[p].name);
                  }
              }
          alert("Total Number of Pages : "+pageNoList.length+ "\rPage No. List: "+pageNoList.join("; "));
          

           

          ~Green4ever

          • 2. Re: Master Pages - PDF
            [Jongware] Most Valuable Participant

            Very good! I suggest one note, one change, and one improvement:

             

            1. The masterPageName needs to be "Prefix-Name", including a dash between the two. The Prefix and Name are those as found in the Master Options dialog.

             

            2. 'myPageName.name' will fail if "[None]" was applied (it has 'no' name). So first check if there *is* a master applied, and only if so, check its name.

             

            3. The page number string can easily be fed into the PDF Export dialog. If you run this script and then call up "Export PDF", you will see the page range contains the correct page numbers.

             

            var myDoc = app.activeDocument;
            var myPages = myDoc.pages;
            var pageLength = myPages.length;
            var masterPageName = "Ch1-Master";
            var myPageName, pageNoList = [];
            for (var p=0; p<pageLength; p++)
            {
            myPageName = myPages[p].appliedMaster;
            if (myPageName)
            {
              myPageName = myPageName.name;
              if (myPageName == masterPageName)
              {
               pageNoList.push(myPages[p].name);
              }
            }
            }
            alert("Total Number of Pages : "+pageNoList.length+ "\r"+
            "Page No. List: "+pageNoList.join(", "));
            app.pdfExportPreferences.pageRange = pageNoList.join(",");
            
            • 3. Re: Master Pages - PDF
              Green4ever Level 3

              Hi Johngware,

               

              Thanks for the three ones (one note, one change, and one improvement).

               

              I'm just lazy to do the remaining things. So I left the remaining work to @KirstenHill123.

               

              ~Green4ever