Page numbers in illustrator
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
Explore related tutorials & articles
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();
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
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
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:
Copy link to clipboard
Copied
Thank you so much for the same. appreciate
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.
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);
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!
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.
Lottie and Rive animation for your web or mobile project.

