39 Replies Latest reply on Aug 10, 2017 1:02 AM by Monika Gause

    Introducing: Insert Page Numbers v 2

    CarlosCanto Adobe Community Professional & MVP

      Hi Everyone, back by popular demand, here's version 2. It now has options for inserting Date, Time, Full Name, and Document Name.

       

      tip: you don't have to click on the "insert" buttons, you can type directly in the input box, for example, type:

      Page *page* of *pages* to get Page 1 of 3

      insertPageNumbersv2.png

       

      download

       

      questions/comments? let me know

       

      enjoy,

      CarlosCanto

        • 1. Re: Introducing: Insert Page Numbers v 2
          [scott] Level 6

          Thank you, Carlos!

          • 2. Re: Introducing: Insert Page Numbers v 2
            Mathias17 Level 3

            Great Cronos, Father of Olympia, we beseach thy favor. Your scripts befall us. And we prostrate our own pitiful forms before thee!

             

             

             

            (thanks, homie)

            • 3. Re: Introducing: Insert Page Numbers v 2
              CarlosCanto Adobe Community Professional & MVP

              hahaha thanks Mathias

               

              thanks Scott

               

              any mac volunteers that may want to post a screen shot? Lion and/or previous?

               

               

              thanks

              Carlos [AKA Cronos of Tartarus]

              • 4. Re: Introducing: Insert Page Numbers v 2
                tromboniator Adobe Community Professional

                Snow Leopard:

                 

                mTools - Insert Page Numbers v 2.png

                Thanks, Carlos Cronos.

                • 5. Re: Introducing: Insert Page Numbers v 2
                  CarlosCanto Adobe Community Professional & MVP

                  thanks Peter, glad to see square buttons instead of round.

                  • 6. Re: Introducing: Insert Page Numbers v 2
                    tromboniator Adobe Community Professional

                    Yeah, I know; I just can't work with those pesky round buttons!

                    • 7. Re: Introducing: Insert Page Numbers v 2
                      emil emil Level 4

                      As always nice job Carlos, last time I needed to do page numbering of Illustrator files I used Acrobat but it wasn't fun there and it increased the pdf size a lot just for keeping the added page numbers. This looks much better.

                      • 9. Re: Introducing: Insert Page Numbers v 2
                        Flobe20

                        Hey Carlos I made a change to the time function to display in 12-hour format hope that is alright, and I wanted to post it in case others would like to use it as well.

                         

                        function gettime() {

                                  var time = new(Date);

                                  var hours = time.getHours();

                         

                                  if(hours > 11){

                                            ampm = "PM";

                                  } else {

                                            ampm = "AM";

                                  }

                         

                                      if(hours > 12){

                                          hours = hours - 12;

                                  }

                         

                                  var minutes = time.getMinutes();

                                  if (minutes < 10){

                                            minutes = "0" + minutes

                                  }

                         

                                  var curtime = hours + ":" + minutes + " " + ampm;

                                  return curtime;

                        }

                        • 10. Re: Introducing: Insert Page Numbers v 2
                          CarlosCanto Adobe Community Professional & MVP

                          no problem, thanks for posting

                          • 11. Re: Introducing: Insert Page Numbers v 2
                            ToryMW

                            Carlos,

                             

                            Your Page Numbering Script is PHENOMINAL!!!

                             

                            It works flawlessly in CS6.

                             

                            Question: How can one alter the font style, weight, size, color, etc of the page numbering text prior to it being populated into the artboards?

                             

                            Would also be beneficial to have the dates appear in different formats, examples:

                             

                            July 9, 2012

                             

                            07.09.2012

                             

                            07/09/2012

                             

                            7/9/2012

                             

                            7/9/12

                             

                            2012.07.09

                             

                            Thank you for taking the time to create this.

                             

                            -Tory

                            • 12. Re: Introducing: Insert Page Numbers v 2
                              CarlosCanto Adobe Community Professional & MVP

                              thanks Tory, I was asked the same thing about the font styling when I released version 1, and my answer was...isn't it the same as doing it with the UI?

                               

                              about the date formats....version 3 perhaps?

                              • 13. Re: Introducing: Insert Page Numbers v 2
                                jarnot9 Level 1

                                It would be really useful for large multi-artboard docs if you could set the font inside the script. Is it possible to pull it from Styles?

                                 

                                Just encountered a glitch in version2:

                                 

                                script window wouldn't close on "OK." Had to force quit. Mac OSX.7.3/Illustrator CS5.1

                                 

                                Thanks for the amazing script. Saved me so much time!

                                • 14. Re: Introducing: Insert Page Numbers v 2
                                  CarlosCanto Adobe Community Professional & MVP

                                  you're welcome, it is not a glitch, it is a feature. The idea is to be able to insert, pages at bottom right, file name at bottom left, etc. without having to fire the program multiple times.

                                   

                                  Press Esc to close.

                                  • 15. Re: Introducing: Insert Page Numbers v 2
                                    jarnot9 Level 1

                                    Ah. OK. Thanks!

                                    • 16. Re: Introducing: Insert Page Numbers v 2
                                      Wade_Zimmerman Level 6

                                      Esc. to close is the thing to always try before force quit.

                                       

                                      I like the feature where you can put the time date and page number in one shot.

                                       

                                      Thanks for the script.

                                       

                                      But have a request probably not doable.

                                       

                                      I write fiction as a hobby. No I am not concerned about my spelling.

                                       

                                      So I might work and a section and then putit aside for a while then resume it would be good to be able create sections and chapters with dates applied the to sections or chapters but no the the whole document!

                                       

                                      Is such a thing possible?

                                       

                                      A very handy device I must say I am for Adobe acquiring it from you.

                                      • 17. Re: Introducing: Insert Page Numbers v 2
                                        CarlosCanto Adobe Community Professional & MVP

                                        Wade_Zimmerman wrote:

                                         

                                        I write fiction as a hobby. No I am not concerned about my spelling.

                                         

                                        that's the funniest thing you've said in a long time. Perfectly spelled!!

                                         

                                         

                                        ...Is such a thing possible?

                                        can you make a mock up by hand? and post it here? If there's some kind of logic to it, it might be possible to implement.

                                         

                                         

                                        A very handy device I must say I am for Adobe acquiring it from you.

                                        me too, anytime...how?

                                        • 18. Re: Introducing: Insert Page Numbers v 2
                                          Lena Shore Level 1

                                          You are absolutely the BOMB DIGGITY! Thank you SO SO much for this. This is something that I have wished for over and over when working on logo designs.

                                           

                                          *virtual warm chocolate chip cookies*

                                           

                                          (:

                                          • 20. Re: Introducing: Insert Page Numbers v 2
                                            Jlaurrieta

                                            Great job! nevertheless, I dared to insert a dirty modification (not a programer myself) to allow user insert page range and first number (for those cases in which the document's got  front page, index, etc), copied bellow.

                                             

                                             

                                            #target illustrator

                                            //#targetengine main

                                             

                                            // script.name = insertPageNumbers_v2.jsx; // works with CS4 & CS5 &C S6

                                            // script description = Inserts page numbers (or any other text) to all artboards in the active document;

                                            // script.required = at least one open document

                                            // script.parent = CarlosCanto // 5/25/12;

                                            // script.elegant = false;

                                             

                                            // script.updates = added options to insert Date, Time, Full File Name, & File Name;

                                            //                                      added a button to clear previous entered data;

                                            //                                       dialog stays open, to be able to input data in multiple locations

                                            //                                       only one layer is created on multiple runs

                                             

                                            // Notes: The script creates a new layer (Page Numbers) then adds a text frame per Artboard that act as footer or header text.

                                            //              Its primary function is to insert Page Numbers, but it could be used to insert any other kind of information.

                                             

                                             

                                             

                                            if (app.documents.length > 0) // continue if there's at leat one document open

                                                {

                                                            // start building User Interface

                                                            var win = new Window("dialog","mTools - Insert Page Numbers v 2");

                                                            var panelMargins = win.add("panel", undefined, "Margins");

                                                            var lblMargins = panelMargins.add("statictext",undefined,"How far from the edge:");

                                                            var txtMargins = panelMargins.add("edittext",undefined, 0.25);

                                                            var lblUnits = panelMargins.add("statictext",undefined,"inches");

                                             

                                                            var panelLocation = win.add("panel", undefined, "Location");

                                                            var radTop = panelLocation.add("radiobutton",undefined,"Top");

                                                            var radBottom = panelLocation.add("radiobutton",undefined, "Bottom");

                                                           

                                                                var trgtPages = win.add("panel", undefined, "Target Pages");

                                                                var lblfrstP = trgtPages.add("statictext",undefined,"From:");

                                                                var frstP = trgtPages.add("edittext",undefined, 1);

                                                                var lbllstP = trgtPages.add("statictext",undefined," - To:");

                                                                var lstP = trgtPages.add("edittext",undefined,app.activeDocument.artboards.length);

                                                                var pNlabel = trgtPages.add("statictext",undefined,"First Number");

                                                                var pN = trgtPages.add("edittext",undefined, 1);

                                             

                                                            var panelAlignment = win.add("panel", undefined, "Alignment");

                                                            var radLeft = panelAlignment.add("radiobutton",undefined,"Left");

                                                            var radCenter = panelAlignment.add("radiobutton",undefined, "Center");

                                                            var radRight = panelAlignment.add("radiobutton",undefined, "Right");

                                             

                                                            var panelFooter = win.add("panel", undefined, "Text to insert");

                                             

                                                            var grpPages = panelFooter.add("group");

                                                            var btnPage = grpPages.add("button",undefined,"P");

                                                            var btnPages = grpPages.add("button",undefined,"Ps");

                                                            var btnDate = grpPages.add("button",undefined,"D");

                                                            var btnTime = grpPages.add("button", undefined, "T");

                                                            var btnFullName = grpPages.add("button", undefined, "fFn");

                                                            var btnFile = grpPages.add("button", undefined, "Fn");

                                             

                                                            var txtFooter = panelFooter.add("edittext"); //,undefined, "[Type text to insert here]");

                                                            var btnClear = panelFooter.add("button", undefined, "C");

                                                            btnPage.size = btnPages.size = btnDate.size = btnTime.size = btnFullName.size = btnFile.size = btnClear.size = [31,24]; // on Mac [31, 21] = round buttons, [31,24] = square buttons

                                             

                                                            var btnOk = win.add("button", undefined, "Ok");

                                             

                                                            radRight.value = radBottom.value = true;

                                             

                                                            win.alignChildren = panelFooter.alignChildren = "fill";

                                                            btnClear.alignment = "left";

                                                            panelMargins.spacing = 3;

                                                            panelMargins.orientation = panelLocation.orientation = panelAlignment.orientation = "row";

                                                          

                                                            win.helpTip = "\u00A9 2012 Carlos Canto";

                                                     btnOk.helpTip = "Press Esc to Close";

                                                            btnPage.helpTip = "Adds *page* keyword, it represents a single page";

                                                            btnPages.helpTip = "Adds *pages* keyword, it represents total number of pages";

                                                            btnDate.helpTip = "Adds *date* keyword, it represents today's date";

                                                            btnTime.helpTip = "Adds *time* keyword, it represents current time";

                                                            btnFullName.helpTip = "Adds *fname* keyword, it represents Full File Name (including path)";

                                                            btnFile.helpTip = "Adds *file* keyword, it represents File Name";

                                                            btnClear.helpTip = "Clears input text area";

                                                            txtFooter.helpTip = "Type \r\t'Page *page* of *pages*' \rto get \r\t'Page 1 of 3' \rfor example";

                                             

                                             

                                                            //--------------------------------------------------------------------------------------- --

                                                            // text place holder by Jongware / Marc Autret

                                                            var wgx = win.graphics;

                                                            var grayPen = wgx.newPen(wgx.PenType.SOLID_COLOR,[.67,.67,.67], 1);

                                             

                                                            txtFooter.onDraw = function(/*DrawState*/)

                                                            {

                                                                    var gx = this.graphics;

                                                                    gx.drawOSControl();

                                                                    this.text || this.active || gx.drawString("[Type text to insert here] Press Esc to close", grayPen, 0, 0);

                                                            };            

                                                          

                                                            //--------------------------------------------------------------------------------------- --

                                                                                            btnOk.onClick = function(){

                                                                        if (txtFooter.text != "")

                                                                                                    doSomething(); // call main function

                                                                                                    //win.close(); // close when done

                                                                                             }

                                                            //--------------------------------------------------------------------------------------- --

                                                          

                                                            //--------------------------------------------------------------------------------------- --

                                                                                            btnClear.onClick = function(){

                                                                                                    txtFooter.text = ""; // call main function

                                                                                                    //win.close(); // close when done

                                                                                             }

                                                            //--------------------------------------------------------------------------------------- --           

                                                            //--------------------------------------------------------------------------------------- --

                                                                                            btnPage.onClick = function(){

                                                                                                    footer("*page*");

                                                                                             }

                                                            //--------------------------------------------------------------------------------------- --

                                                            //--------------------------------------------------------------------------------------- --

                                                                                            btnPages.onClick = function(){

                                                                                                    footer("*pages*");

                                                                                             }

                                                            //--------------------------------------------------------------------------------------- --

                                                            //--------------------------------------------------------------------------------------- --

                                                                                            btnDate.onClick = function(){

                                                                                                    footer("*date*");

                                                                                             }

                                                            //--------------------------------------------------------------------------------------- --

                                                            //--------------------------------------------------------------------------------------- --

                                                                                            btnTime.onClick = function(){

                                                                                                    footer("*time*");

                                                                                             }

                                                            //--------------------------------------------------------------------------------------- --

                                                            //--------------------------------------------------------------------------------------- --

                                                                                            btnFullName.onClick = function(){

                                                                                                    footer("*fname*");

                                                                                             }

                                                            //--------------------------------------------------------------------------------------- --

                                                            //--------------------------------------------------------------------------------------- --

                                                                                            btnFile.onClick = function(){

                                                                                                    footer("*file*");

                                                                                             }

                                                            //--------------------------------------------------------------------------------------- --

                                                                                            win.center();

                                                                                            win.show();

                                                                                          

                                                            //--------------------------------------------------------------------------------------- --

                                             

                                             

                                                            function footer (page) //

                                                                    {

                                                                            txtFooter.text = txtFooter.text + page;

                                                                    }

                                             

                                                            function doSomething()

                                                                    {

                                                                            //alert("I'm doing something");

                                                                            var idoc = app.activeDocument;

                                                                            try {

                                                                                    var ilayer = idoc.layers["Page Numbers"];

                                                                            } catch(e) {

                                                                                    var ilayer = idoc.layers.add();

                                                                                    ilayer.name = "Page Numbers";

                                                                            }

                                             

                                                                            var pages = idoc.artboards.length; // number of artboards

                                                                            var datee = getdate ();

                                                                            var timee = gettime ();

                                                                            var fname = idoc.path == '' ? "Full Name: <unsaved document>" : idoc.fullName;

                                                                            var file = idoc.name;

                                                                          

                                                                            var footerPages = (txtFooter.text).replace("*pages*",pages);

                                                                            //$.writeln(msg);

                                                                            footerPages = footerPages.replace("*pages*",pages); // replace the "*pages*" keyword with the actual number fo pages (artboards)

                                                                            footerPages = footerPages.replace("*date*",datee);

                                                                            footerPages = footerPages.replace("*time*",timee);

                                                                            footerPages = footerPages.replace("*fname*",fname);

                                                                            footerPages = footerPages.replace("*file*",file);

                                                                          

                                                                            var margins = Number(txtMargins.text)*72; // get margins in points

                                                                            //$.writeln(margins);

                                              var n =Number(pN.text)-1;

                                                                                                                  

                                                                            for (i = Number(frstP.text)-1; i<Number(lstP.text); i++) // loop thru all artboards, and add input text from UI

                                                                           

                                                                                    {

                                                                                            footerPage = footerPages.replace("*page*",n+1); // replace "*page*" keyword with the actual page Number

                                                                                  

                                                                                            var itext = ilayer.textFrames.add();

                                                                                            itext.contents = footerPage; //"page 1 of 1";                         

                                                                                            var fontSize = itext.textRange.characterAttributes.size;

                                                                                          

                                                                                            var activeAB = idoc.artboards[i];

                                             

                                                                                            var iartBounds = activeAB.artboardRect;

                                                                                          

                                                                                            var ableft = iartBounds[0]+margins;

                                                                                            var abtop = iartBounds[1]-margins;

                                                                                            var abright = iartBounds[2]-margins;

                                                                                            var abbottom = iartBounds[3]+margins+fontSize;

                                                                                          

                                                                                            var abcenter = ableft+(abright-ableft)/2;

                                                                                                          

                                             

                                                                          

                                                                                            if (radRight.value == true)

                                                                                                    {

                                                                                                            //var msg = "right";

                                                                                                            itext.left = abright;

                                                                                                            itext.textRange.paragraphAttributes.justification = Justification.RIGHT;

                                                                                                    }

                                                                                            else if (radCenter.value == true)

                                                                                                    {

                                                                                                            //var msg = "center";

                                                                                                            itext.left = abcenter;

                                                                                                            itext.textRange.paragraphAttributes.justification = Justification.CENTER;

                                                                                                    }

                                                                                            else

                                                                                                    {

                                                                                                            //var msg = "Left";

                                                                                                            itext.left = ableft;

                                                                                                            itext.textRange.paragraphAttributes.justification = Justification.LEFT;

                                                                                                    }

                                             

                                                                                            if (radTop.value == true)

                                                                                                    {

                                                                                                            //var msg = "top";

                                                                                                            itext.top = abtop;

                                                                                                    }

                                                                                            else

                                                                                                    {

                                                                                                            //var msg = "bottom";

                                                                                                            itext.top = abbottom;

                                                                                                    }

                                                                                                n=n+1;

                                                                                    } // end for loop thru all artboards

                                                                            app.redraw();

                                                                    } // end function doSomething();

                                                 }

                                            else

                                                {

                                                    alert ("there's no open documents");

                                                }

                                             

                                            function getdate() {

                                                    var date = new(Date);

                                                    var m = date.getMonth()+1;

                                                    var d = date.getDate();

                                                    var y = date.getFullYear();

                                                    var datemdy = m+"/"+d+"/"+y;

                                                    return datemdy;

                                            //alert(date);

                                            //alert(m+"/"+d+"/"+y);

                                            }

                                             

                                            function gettime() {

                                                    var time = new(Date);

                                                    var hours = time.getHours();

                                                    var minutes = time.getMinutes();

                                                    if (minutes < 10){

                                                            minutes = "0" + minutes

                                                    }

                                             

                                                    if(hours > 11){

                                                            ampm = "PM";

                                                    } else {

                                                            ampm = "AM";

                                                    }     

                                                    var curtime = hours + ":" + minutes + " " + ampm;

                                                    return curtime;

                                            }

                                            • 21. Re: Introducing: Insert Page Numbers v 2
                                              mike_curious Level 1

                                              Um, how do I install this?

                                              • 22. Re: Introducing: Insert Page Numbers v 2
                                                Lena Shore Level 1

                                                First - use the download link at the top of the page in the first post (http://pastebin.com/UvNKrZgP)

                                                 

                                                Then place it here: Applications --> Adobe Illustrator --> Scripting --> Page Numbering (this folder includes both the downloaded files)

                                                 

                                                 

                                                • 23. Re: Introducing: Insert Page Numbers v 2
                                                  Petros_ Level 1

                                                  Didn't work for me, I get this error:

                                                   

                                                  Screen Shot 2013-12-05 at 11.42.09 AM.png

                                                  I'm on a Mac running CS6.

                                                  • 24. Re: Introducing: Insert Page Numbers v 2
                                                    WineDesignGuy Level 1

                                                    You sir, are amazing awesome.  Thank you!

                                                    • 25. Re: Introducing: Insert Page Numbers v 2
                                                      farleonhart

                                                      Hi, 1 question here. I'd like to know how do I add pagination to my work, which has 8 artboards? Since this script only add pagination from 1-100, i couldn't find any solution to allow the script to add page 100 and above. I believe I just need to modify a thing or two in the script but i'm totally noob when it comes to computer language LOL. Pls help.

                                                       

                                                      EDIT: Oh never mind. It turns out that it was quite easy to indentify which part I should modify to add page 100 and above. Problem Solved.

                                                       

                                                      Message was edited by: farleonhart

                                                      • 26. Re: Introducing: Insert Page Numbers v 2
                                                        Sullfam

                                                        Trying to follow your uinstructions, but there is no folder called Page Numbering and the download only includes one file?

                                                         

                                                        Help!!

                                                         

                                                        Marty

                                                        • 27. Re: Introducing: Insert Page Numbers v 2
                                                          CarlosCanto Adobe Community Professional & MVP

                                                          you have to make the folder yourself, or just drop it here Applications --> Adobe Illustrator --> Scripting

                                                           

                                                          correct, the download has 1 file only, that's all you need.

                                                          • 28. Re: Introducing: Insert Page Numbers v 2
                                                            Alessandro.Anconetani

                                                            Hello Carlos, congratulations for the great work !! I

                                                            try to ask a question and I am attaching a picture.

                                                            Do you think i can enter the file name and the date on a identification form like the one in the picture, where you see filename dates field?
                                                            thank you !!!!!!

                                                             

                                                            mask.jpg
                                                            • 29. Re: Introducing: Insert Page Numbers v 2
                                                              Jlaurrieta Level 1

                                                              I guess you would have to make a function to position *Filename* and an other one to position *Date*.

                                                              • 30. Re: Introducing: Insert Page Numbers v 2
                                                                CarlosCanto Adobe Community Professional & MVP

                                                                it could be done, the script needs to be reworked or probably a new one with that functionality would be a better option.

                                                                • 31. Re: Introducing: Insert Page Numbers v 2
                                                                  Alessandro.Anconetani Level 1

                                                                  Thank you Carlos!!!

                                                                  Can you help me to do this?!!!!!!

                                                                  I do not know scripting !!!!

                                                                  Thanks in advance

                                                                   

                                                                  • 32. Re: Introducing: Insert Page Numbers v 2
                                                                    -steelie-

                                                                    FYI, it works perfectly in CC 2014.

                                                                    Having it create a unique layer for the numbering is brilliant! It makes it dead-simple to select, move and format them all at the same time.

                                                                     

                                                                    Many, many thanks for this!

                                                                    • 33. Re: Introducing: Insert Page Numbers v 2
                                                                      Roger Sawhill Level 1

                                                                      Awesome Script Carlos! I use it to quickly label pages with different designs for presentation. Saves tons of time.

                                                                      • 34. Re: Introducing: Insert Page Numbers v 2
                                                                        Zivago

                                                                        Great script, many thanks!

                                                                        Question: can somebody help what part of the script controls page number/text font size, color & type or how I could add it to the script? Or point me to some good tutorials how to learn to do this.

                                                                        • 35. Re: Introducing: Insert Page Numbers v 2
                                                                          CarlosCanto Adobe Community Professional & MVP

                                                                          you're welcome, look here for info on to get started with illustrator scripting

                                                                           

                                                                          Illustrator Scripting | Adobe Developer Connection

                                                                          • 36. Re: Introducing: Insert Page Numbers v 2
                                                                            mc48097807

                                                                            this is amazing! thank you! I have a question, and sorry if it has been asked before... can you select which page number you would like it to start from. I have split my document into many files, as it's huge and i don't want to have to wait so long to save it each time, so e.g.  I need the second file to start from page 15, the third file to start from 25 etc
                                                                            No worries if not.
                                                                            Thanks again

                                                                            • 37. Re: Introducing: Insert Page Numbers v 2
                                                                              CarlosCanto Adobe Community Professional & MVP

                                                                              yes, it's possible. I'll add that functionality as soon as I have a chance.

                                                                               

                                                                              stay tuned,

                                                                              Carlos

                                                                              • 38. Re: Introducing: Insert Page Numbers v 2
                                                                                Lâm Ngô

                                                                                Great script! Thank you so much!

                                                                                I have some question: how can I change the color of text? Sometimes I got a dark background and I need light text on it! and how can I change the size of the text?

                                                                                • 39. Re: Introducing: Insert Page Numbers v 2
                                                                                  Monika Gause Adobe Community Professional & MVP

                                                                                  THose are just default text objects. Style them to your desire.