Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
15

Introducing: Insert Page Numbers v 2

Community Expert ,
May 29, 2012 May 29, 2012

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

43.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
May 29, 2012 May 29, 2012

Thank you, Carlos!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 29, 2012 May 29, 2012

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

(thanks, homie)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2012 May 29, 2012

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]

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2012 May 29, 2012

Snow Leopard:

mTools - Insert Page Numbers v 2.png

Thanks, Carlos Cronos.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2012 May 30, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2012 May 30, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 30, 2012 May 30, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2012 May 30, 2012

thanks emil

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2012 Jun 23, 2012

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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 23, 2012 Jun 23, 2012

no problem, thanks for posting

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 08, 2012 Jul 08, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 09, 2012 Jul 09, 2012

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 14, 2012 Sep 14, 2012

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2012 Sep 14, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 20, 2012 Sep 20, 2012

Ah. OK. Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 20, 2012 Sep 20, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2012 Sep 20, 2012

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 17, 2013 Oct 17, 2013

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*

(:

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 17, 2013 Oct 17, 2013

thanks Lena

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 20, 2013 Nov 20, 2013

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;

                                                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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 11, 2019 Dec 11, 2019

Hello, I do realize this was a long time ago but maybe I could still get some help. This modification is exactly what I was looking for after Carlos´s original page numbering. The dialog box seems to have the options needed, to start numbering from x page to x page and start with x #. However, after filling the needed info and clicking ok just the #1 appears on top (outside the page actually) of a random page and nothing else. Am I doing something wrong? Verified to copy and paste the correct text from top to bottom twice. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 29, 2023 Mar 29, 2023

Hey msando,

 

I know you posted this question almost four years ago, but I am having the same issue.

Did you ever find a solution?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 27, 2013 Nov 27, 2013

Um, how do I install this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 27, 2013 Nov 27, 2013

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines