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

Is there a way to paste the File name into the document

Engaged ,
Oct 05, 2018 Oct 05, 2018

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!

TOPICS
Scripting

Views

543

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 05, 2018 Oct 05, 2018

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", "");

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 Expert ,
Oct 05, 2018 Oct 05, 2018

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

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 05, 2018 Oct 05, 2018

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
}

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 Expert ,
Oct 06, 2018 Oct 06, 2018

Copy link to clipboard

Copied

LATEST

Hi

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