Anton, this should be pretty close for a guide… I don't know what your exact font name would be… so this uses my closest match. Also you don't mention text positioning on the artboard/doc… The stroke is default 1pt as is. The height of the outlined text would be dependent on your font and you may have to tinker with the size where shown… #target illustrator
function docNameToText() {
if (app.documents.length = 0) {
return;
} else {
var docRef = app.activeDocument;
var docName = docRef.name;
var text = docName.replace(/\.(ai|eps|pdf)$/i,'');
var arialFont = app.textFonts.getByName('ArialMT-Bold'); // Add font name here…
var nameText = docRef.textFrames.add();
nameText.contents = text;
var nameChar = nameText.lines[0].characters;
for (var i = 0; i < nameChar.length; i++) {
nameChar.characterAttributes.textFont = arialFont;
nameChar.characterAttributes.size = 40; // Adjust font size here…
}
var textGroup = nameText.createOutline();
textGroup.position = [36,-36]; // Half Inch down/across from top/left
var groupBounds = textGroup.visibleBounds;
var ccLayer = docRef.layers.getByName('CC');
textGroup.move(ccLayer, ElementPlacement.INSIDE);
var artLayer = docRef.layers.getByName('Artwork');
// This can't be the right way to do this now can it?
var boxTop = groupBounds[1] + 4;
var boxLeft = groupBounds[0] - 4;
var boxWidth = (groupBounds[2] - groupBounds[0]) + 8;
var boxHeight = (-groupBounds[3] - -groupBounds[1]) + 8;
var spotBox = docRef.pathItems.rectangle(boxTop,boxLeft,boxWidth,boxHeight);
spotBox.filled = false;
spotBox.stroked = true;
//spotBox.strokeWidth = 1; // Default is 1pt
var ccSpot = docRef.swatches.getByName('CC');
spotBox.strokeColor = ccSpot.color;
textGroup.move(artLayer, ElementPlacement.INSIDE);
}
};
docNameToText();
... View more