Copy link to clipboard
Copied
Hello,
Is there a script out there that can add the file name file name within the artboard of illustrator? If that's possible, I'd like to add the text "Order# " and drop the file extension. Then place it aligned Left and Bottom to the art. In a specific font and size.
Does anyone know if/how this could be done?
Thank you!
Copy link to clipboard
Copied
Hey, just have a text frame wherever you want it with the correct font size, etc in it and ensure it's named a name that we can later reference such as "file_name".
Then you can use:
app.activeDocument.textFrames["file_name"].contents = "Order# " + app.activeDocument.name.replace(".ai", "");
Copy link to clipboard
Copied
place these lines in front of Silly-V code
var aTF = app.activeDocument.textFrames.add();
aTF.name = "file_name";
aTF.rotate(90);
aTF.position = [app.activeDocument.artboards[0].artboardRect[0], app.activeDocument.artboards[0].artboardRect[3]];
… and have fun
Copy link to clipboard
Copied
var content="love";
var font=app.textFonts[0];
var size=12;
var color=getCMYKColor(0,100,100,0);
newGroup = app.activeDocument.groupItems.add();
addText(10,0,content,font,size,color,0).moveToBeginning( newGroup );
addText(0,-10*1,content,font,size,color,45).moveToBeginning( newGroup );
addText(0,-10*2,content,font,size,color,90).moveToBeginning( newGroup );
function addText(x,y,content,font,size,color,rotate){
var pt=72/25.4;
var text = app.activeDocument.activeLayer.textFrames.add();
text.left=x*pt;
text.top =y*pt;
text.contents = content;
text.textRange.characterAttributes.size=size;
text.rotate(rotate);
//text.textRange.characterAttributes.textFont = textFonts.getByName(font);
text.textRange.characterAttributes.textFont = font;
text.textRange.characterAttributes.fillColor = color;
//textRef1.createOutline( );
return text;
}
function getRegColor(){
var docRef = app.activeDocument;
var newSpot = docRef.swatches;
for(var i=0;i<newSpot.length;i++){
var swatch1 = docRef.swatches[i];
if(swatch1.color=='[SpotColor]'){
var spot2 = swatch1.color.spot;
var colorType2 = spot2.colorType;
if(colorType2.toString()== "ColorModel.REGISTRATION") {
regColorIndex=i; }
}else{
continue;
}
}
return docRef.swatches[regColorIndex].color;
}
function getCMYKColor(c,m,y,k){
var color = new CMYKColor();
color.cyan= c;
color.magenta = m;
color.yellow = y;
color.black = k;
return color
}
Copy link to clipboard
Copied
Hi 滔周19517892
if this is your own code:
good job and welcome to the Illustrator scripting community
If this code is not written by yourself (eg from cnprint.org) please give credits to the author and mention his name.
Thanx