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

Page numbers in illustrator

New Here ,
Oct 17, 2017 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

13.1K

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
community guidelines
Adobe
Valorous Hero ,
Oct 17, 2017 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();

Votes

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
community guidelines
New Here ,
Oct 17, 2017 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

Votes

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
community guidelines
New Here ,
Oct 18, 2017 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

Votes

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
community guidelines
Valorous Hero ,
Oct 18, 2017 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

Votes

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
community guidelines
New Here ,
Oct 18, 2017 Oct 18, 2017

Copy link to clipboard

Copied

Thank you so much for the same. appreciate

Votes

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
community guidelines
Community Beginner ,
Jul 17, 2018 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.

Votes

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
community guidelines
Valorous Hero ,
Jul 18, 2018 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);

Votes

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
community guidelines
Community Beginner ,
Jul 18, 2018 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!

Votes

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
community guidelines
Explorer ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

LATEST

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.

___
Lottie and Rive animation for your web or mobile project.

Votes

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
community guidelines