10 Replies Latest reply on Mar 17, 2016 11:42 AM by Vamitul

    Sequential page numbering on odd pages

    kermitr20850467

      I have many InDesign files with hundred of pages that I need to add a page number too to denote sign the sign number. The customer has an existing text box with a code already on it from a master page, but I need to add a page number too it. I can do that manually do that by inserting the current page character.

       

      My problem is the indd files are with odd pages as fronts, then even pages are the backs. So if I use page numbering in my text box on the master page applied to my odd pages, my sign numbers goes 1, 3, 5, 7..., but I need them to go 1, 2, 3, 4.

       

      My thoughts are that I could tell the odd pages to use the Numbering and Section Options, and have odd pages to use  Start Page Page Numbering at 1, then 2, then 3 and so on. Would there be a way to do with applescript is possible? Still kind of a newbie with scripting, but prefer applescript. Could anyone help me with the script? Or is there a better way to accomplish this?

        • 1. Re: Sequential page numbering on odd pages
          kermitr20850467 Level 1

          Here's what I have so far, but since I only need the number on odd pages, but the pages are numbered 1,3,5,7 instead of 1,2,3,4...

          Any idea how I could cycle through all of the odd pages, as a new section starting at 1, then 2, then 3 and so on?

          My page count might be anywhere from 2 to 300 or more.

          I am using leading zeros to below to make 3 digits.

           

          tell application "Adobe InDesign CC 2015"

            set myDocument to active document


           

           

            tell active document

            set active page of layout window 1 of myDocument to page 1 of myDocument

            end tell


           

            set page number style of section 1 of myDocument to double leading zeros

           

            tell document 1 to close saving yes

          end tell

          • 2. Re: Sequential page numbering on odd pages
            Vamitul Level 4

            How about instead of bothering with section numbering you just replace the automatic page number marker with static numbers?
            like this:

             

            (function() {
              Numberer = {
              doc: app.activeDocument,
              masterFrames: {}
              };
              Numberer.processMasters = function() {
              var entries = this.findGrep(true);
              var tf, pag;
              for (var i = 0; i < entries.length; i++) {
              tf = entries[i].parentTextFrames[0];
              if (tf && tf.parent.constructor.name == 'MasterSpread') {
              this.masterFrames[tf.parent.name] = this.masterFrames[tf.parent.name] || [];
              this.masterFrames[tf.parent.name].push(tf)
              }
              }
              for (var i = 0; i < this.doc.pages.length; i++) {
              pag = this.doc.pages[i];
              if (pag.appliedMaster && this.masterFrames[pag.appliedMaster.name]) {
              this.overrideFrame(this.masterFrames[pag.appliedMaster.name], pag);
              }
              }
              };
              Numberer.overrideFrame = function(frames, pag) {
              var pi;
              for (var i = 0; i < frames.length; i++) {
              try {
              pi = frames[i].override(pag);
              //guarding against a rare bug;
              pi.geometricBounds = frames[i].geometricBounds;
              } catch (e) {};
              }
              };
              Numberer.findGrep = function(includeMP) {
              app.findGrepPreferences = app.changeGrepPreferences = app.findChangeGrepOptions = null;
              app.findChangeGrepOptions.includeMasterPages = includeMP;
              app.findGrepPreferences.findWhat = '~N';
              return this.doc.findGrep();
              };
              Numberer.pad = function(num, size) {
              var s = num + "";
              while (s.length < size) s = "0" + s;
              return s;
              };
              Numberer.processMarkes = function() {
              var entries = this.findGrep(false);
              var zeros = this.doc.pages.length.toString(10).length;
              var pag;
              for (var i = entries.length - 1; i >= 0; i--) {
              pag = entries[i].parentTextFrames[0];
              if (!pag) {
              continue;
              }
              pag = pag.parentPage;
              entries[i].contents = pag.documentOffset % 2 ? this.pad(Math.ceil(pag.documentOffset / 2), zeros) : '';
              }
              }
              Numberer.run = function() {
              this.processMasters();
              this.processMarkes();
              }
              Numberer.run();
            }())
            
            • 3. Re: Sequential page numbering on odd pages
              Vamitul Level 4

              May I ask some forum admin why the post above needed moderating? I mean, if we can't post scripts on the SCRIPTING FORUM, what's the point?

              • 4. Re: Sequential page numbering on odd pages
                Obi-wan Kenobi Adobe Community Professional

                Hi,

                 

                Can we see a odd/even page?  ;-)

                • 5. Re: Sequential page numbering on odd pages
                  Obi-wan Kenobi Adobe Community Professional

                  Hi Vamitul,

                   

                  I've an error on line 54! 

                  • 6. Re: Sequential page numbering on odd pages
                    Obi-wan Kenobi Adobe Community Professional

                    I do it with a simple auto-numbering on the right page. The only thing to do is liberate this master page element and "stitch" them on the current pages.

                     

                    Capture d’écran 2016-03-16 à 23.39.53.png

                    • 7. Re: Sequential page numbering on odd pages
                      Vamitul Level 4

                      Obi-wan Kenobi That's helpful.. what error?

                      • 8. Re: Sequential page numbering on odd pages
                        kermitr20850467 Level 1

                        Obi, What do you mean by "stitch"? Unfortunately, I am using not using facing pages.

                        • 9. Re: Sequential page numbering on odd pages
                          kermitr20850467 Level 1

                          Vamitul,I tried your script and it worked perfect! Sometimes though, if my page count is under 100, I will use a 2 digit number, so 1 thru 9, would be 01, 02, 03... to 99. What what would I need to change on your script to accomplish? Primarily having only used applescript, I have no idea where to modify.

                          • 10. Re: Sequential page numbering on odd pages
                            Vamitul Level 4

                            nothing. it already pads the numbers wit as many zeros as needed.