Highlighted

Page numbers in illustrator

New Here ,
Oct 17, 2017

Copy link to clipboard

Copied

Hi,

I have the script for inserting page numbers in Illustrator, but the problem

I face is there are 2 files of about 50 pages each. The first file I can insert

the page numbers from 1-50, but the second file, am not able to insert

from 51 onwards, need help on this please. thanks

felix

TOPICS
Scripting

Views

10.4K

Likes

Translate

Translate

Report

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

Page numbers in illustrator

New Here ,
Oct 17, 2017

Copy link to clipboard

Copied

Hi,

I have the script for inserting page numbers in Illustrator, but the problem

I face is there are 2 files of about 50 pages each. The first file I can insert

the page numbers from 1-50, but the second file, am not able to insert

from 51 onwards, need help on this please. thanks

felix

TOPICS
Scripting

Views

10.4K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 17, 2017 0
Adobe Community Professional ,
Oct 17, 2017

Copy link to clipboard

Copied

Would this help you?

#target illustrator

function test(){

  var doc = app.activeDocument;

  var startNum = prompt("Specify the starting index", "1");

  if(startNum == null || !startNum){

    return;

  }

  startNum *= 1;

  if(isNaN(startNum)){

    alert("Not a valid number");

    return;

  }

  var newText, thisRect;

  var pageNumLayer = doc.layers.add();

  pageNumLayer.name = "Page Numbers";

  var counter = startNum;

  for(var i = 0;  i < doc.artboards.length;  i++){

    newText = pageNumLayer.textFrames.add();

    newText.contents = counter++;

    thisRect = doc.artboards.artboardRect;

    newText.position = [thisRect[2] - 20, thisRect[3] + 20];

  };

};

test();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 17, 2017 1
New Here ,
Oct 17, 2017

Copy link to clipboard

Copied

Thanks for the qick response. but how do I save the above script as Java Script.

please help. thanks in advance

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 17, 2017 0
New Here ,
Oct 18, 2017

Copy link to clipboard

Copied

Hello,

Thanks, it works, but could you please add the coding to the image below. otherwise it works. Because we need to specify the margin as show. Much appreciate and thanks a lot

Screen Shot 2017-10-18 at 12.45.31 PM.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 18, 2017 0
Adobe Community Professional ,
Oct 18, 2017

Copy link to clipboard

Copied

I'm sorry, you will have to try and obtain help from the creator of such a window: Carlos Canto.

The best I could do is just this:

coding-in-image.jpg

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 18, 2017 2
New Here ,
Oct 18, 2017

Copy link to clipboard

Copied

Thank you so much for the same. appreciate

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 18, 2017 0
Community Beginner ,
Jul 17, 2018

Copy link to clipboard

Copied

i stumble upon in this code but having trouble to add the font style and size for this code any ideas on this thank you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 17, 2018 0
Adobe Community Professional ,
Jul 18, 2018

Copy link to clipboard

Copied

to do size, you simply have to do this:

newText.textRange.characterAttributes.size = 12;

to do font style though, you have to know your system's font names.

Get the font names by using this script:

#target illustrator

function test(){

var arr = [];

var destFile = File("~/Desktop/My-Illustrator-Scripting-Text-Fonts.txt");

  for(var i = 0; i < app.textFonts.length; i++){

  arr.push(app.textFonts.name);

  }

  destFile.open("w");

  destFile.write(arr.join("\n"));

  destFile.close();

  destFile.execute();

};

test();

Now you can set the font with this line:

var fontName = "ArialMT"; // my system's 'Arial' font name

newText.textRange.characterAttributes.textFont = app.textFonts.getByName(fontName);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 18, 2018 1
Community Beginner ,
Jul 18, 2018

Copy link to clipboard

Copied

thank you i saw the list

this is what i need to come up the auto numbering

and what i did i use your code and arrange the x and y for that single number maybe got spare time

can manage to create this numbering with standard color and size

font name arial size 15pt

color gray

Silly-V​ super thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 18, 2018 1
New Here ,
Sep 21, 2020

Copy link to clipboard

Copied

Thank you for the script. One important note for those who search multiply digits creation: before starting script you'll need to create a document with specific numbers of artboards. So 100 arbords + script will create 100 numbers.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2020 0