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

A script in illustrator that will create text that matches the file name of a raster image (jpg)

Community Beginner ,
Dec 05, 2023 Dec 05, 2023

Copy link to clipboard

Copied

I don't know if this is somethig that's possible. But at my work I have a lot of survey photos I have to place in with my artwork. Usually the file names of the photos have information that I have to re-type. So say there's a photo of an empty patch of land, the file name will be named something like 'sign placed here left of hydrant'. I have to go and re-type that. I'm wondering if it's possible to create a script that can just generate that text? Thanks for any help. 

TOPICS
How-to , Scripting

Views

342

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

correct answers 1 Correct answer

Enthusiast , Dec 05, 2023 Dec 05, 2023

You may be able to use my addLinkedFileNames.jsx script, which was written for similar purposes.

addLinkedFileNames.gif

Votes

Translate

Translate
Adobe
Enthusiast ,
Dec 05, 2023 Dec 05, 2023

Copy link to clipboard

Copied

You may be able to use my addLinkedFileNames.jsx script, which was written for similar purposes.

addLinkedFileNames.gif

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 ,
Dec 05, 2023 Dec 05, 2023

Copy link to clipboard

Copied

Perfect! That's exactly what I needed. Thank you so much.

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
Advisor ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

You could pimp it a bit. Let it place it automatically at the top left. Save you editing 🙂

Data is the filename, obj is linkedItem, pos is position of linked object. But i use different method for that inside the function. This one centers it at the top. Please Noet, pickedColor is defined outside this function. So that would need something else

 

 

function placeTextLabel(data, obj, pos){
    var docRef = app.activeDocument;
    // obj.selected = true;
    // alert(docRef.activeLayer.visible)

    returnVisibleLayer(docRef.layers.length);
    var pathRef = obj;
    	//Create a textFrame and set its contents to areaMessage.
	var areaLabel = app.activeDocument.activeLayer.textFrames.add();
	areaLabel.contents = data; //.join("\n");
	for(i=0;i<areaLabel.paragraphs.length;i++){
		areaLabel.paragraphs[i].justification=Justification.LEFT;
		areaLabel.paragraphs[i].fillColor = pickedColor;
	}
	// areaLabel.position = pos;
	//Position areaLabel at the center of the selected path.
	areaLabel.top = pathRef.top+areaLabel.height+4;//-pathRef.height/2+areaLabel.height/2;
	areaLabel.left = pathRef.left+pathRef.width/2-areaLabel.width/2;

}

 

 

EDIT
Actually it does have it, though it works different i see. I places it over the image. 
If you replace lines 65-67 with this, it will move it to the top of the image. No need to manually adjust it then

tf.top = obj.top+tf.height+4;
tf.left = obj.left+obj.width/2-tf.width/2;

 

Result old vs new
Old method > text is over imageOld method > text is over imageNew method > text is at top of imageNew method > text is at top of image

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
Enthusiast ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

Certainly the caption above the top of the image is easier to see 👍 I couldn't find my chat from six months ago with the designer about this script. He didn't seem to need the positioning. The text in the center of the image is definitely not confusing as to what it refers to 🙂 The GIF is old, in the latest version of the script I automatically selected all created text, just so the user can move it where they want, or leave it in the center.

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
Enthusiast ,
Jan 27, 2025 Jan 27, 2025

Copy link to clipboard

Copied

LATEST

Released a new script ShowObjectNames, which got a dialog with custom caption placement and support for the names of any selected objects. addLinkedFileNames.jsx is deprecated

ShowObjectNames.gif

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