Highlighted

Adobe Illustrator Script for Annotations

Community Beginner ,
Sep 22, 2020

Copy link to clipboard

Copied

Does anyone know if there is a Adobe Illustrator script capable of creating an annotation like this?

 

More specifically, drawing a stroked box around the text and showing the formatting info to the side?

Thanks

Simon

 

Screenshot 2020-09-22 at 13.30.45.png

Alternatively, see if this works for you:

var text1 = app.selection[0];
  if (text1 == undefined || text1.typename != "TextFrame") {
    alert("You did not select a textFrame.");
  } else {
var string = "Family:  " + text1.textRange.characterAttributes.textFont.family + "\
Name:  " + text1.textRange.characterAttributes.textFont.name + "\
Style:  " + text1.textRange.characterAttributes.textFont.style + "\
Size:  " + text1.textRange.characterAttributes.size + "\
Leading:  " + text1.textRange.characterAttributes.leading + "\
Tracking:  " + text1.textRange.characterAttributes.tracking;
  }
var top = app.selection[0].position[1];
var left = app.selection[0].position[0];
var h = app.selection[0].height;
var w = app.selection[0].width;
var rect1 = app.activeDocument.pathItems.rectangle(top, left, w, h);
rect1.strokeColor = app.activeDocument.swatches["CMYK Cyan"].color;
rect1.strokeWidth = 2.5;
rect1.filled = false;
var rect2 = app.activeDocument.pathItems.rectangle(top, left-200, 200, 200);
rect2.stroked = false;
var text2 = app.activeDocument.textFrames.areaText(rect2);
text2.contents = string;
text2.textRange.characterAttributes.textFont = textFonts["ArialMT"];
text2.textRange.characterAttributes.size = 15;
text2.textRange.fillColor = app.activeDocument.swatches["CMYK Cyan"].color;

Untitled.2021png.png

TOPICS
Scripting

Views

152

Likes

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

Adobe Illustrator Script for Annotations

Community Beginner ,
Sep 22, 2020

Copy link to clipboard

Copied

Does anyone know if there is a Adobe Illustrator script capable of creating an annotation like this?

 

More specifically, drawing a stroked box around the text and showing the formatting info to the side?

Thanks

Simon

 

Screenshot 2020-09-22 at 13.30.45.png

Alternatively, see if this works for you:

var text1 = app.selection[0];
  if (text1 == undefined || text1.typename != "TextFrame") {
    alert("You did not select a textFrame.");
  } else {
var string = "Family:  " + text1.textRange.characterAttributes.textFont.family + "\
Name:  " + text1.textRange.characterAttributes.textFont.name + "\
Style:  " + text1.textRange.characterAttributes.textFont.style + "\
Size:  " + text1.textRange.characterAttributes.size + "\
Leading:  " + text1.textRange.characterAttributes.leading + "\
Tracking:  " + text1.textRange.characterAttributes.tracking;
  }
var top = app.selection[0].position[1];
var left = app.selection[0].position[0];
var h = app.selection[0].height;
var w = app.selection[0].width;
var rect1 = app.activeDocument.pathItems.rectangle(top, left, w, h);
rect1.strokeColor = app.activeDocument.swatches["CMYK Cyan"].color;
rect1.strokeWidth = 2.5;
rect1.filled = false;
var rect2 = app.activeDocument.pathItems.rectangle(top, left-200, 200, 200);
rect2.stroked = false;
var text2 = app.activeDocument.textFrames.areaText(rect2);
text2.contents = string;
text2.textRange.characterAttributes.textFont = textFonts["ArialMT"];
text2.textRange.characterAttributes.size = 15;
text2.textRange.fillColor = app.activeDocument.swatches["CMYK Cyan"].color;

Untitled.2021png.png

TOPICS
Scripting

Views

153

Likes

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
Sep 22, 2020 1
Engaged ,
Sep 22, 2020

Copy link to clipboard

Copied

This should give you the properties of a selected textFrame in an alert window. 

var text1 = app.selection[0];
  if (text1 == undefined || text1.typename != "TextFrame") {
    alert("You did not select a textFrame.");
  } else {
    alert("family:  " + text1.textRange.characterAttributes.textFont.family + "\
Name:  " + text1.textRange.characterAttributes.textFont.name + "\
Style:  " + text1.textRange.characterAttributes.textFont.style + "\
Size:  " + text1.textRange.characterAttributes.size + "\
Leading:  " + text1.textRange.characterAttributes.leading + "\
Tracking:  " + text1.textRange.characterAttributes.tracking);
  }

It is possible to make it into text in the document, but then you will have to delete it once you have finished with it. 

Likes

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
Reply
Loading...
Sep 22, 2020 0
Community Beginner ,
Sep 22, 2020

Copy link to clipboard

Copied

That's amazing thanks Femkeblanco

Likes

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
Reply
Loading...
Sep 22, 2020 0
Engaged ,
Sep 22, 2020

Copy link to clipboard

Copied

Alternatively, see if this works for you:

var text1 = app.selection[0];
  if (text1 == undefined || text1.typename != "TextFrame") {
    alert("You did not select a textFrame.");
  } else {
var string = "Family:  " + text1.textRange.characterAttributes.textFont.family + "\
Name:  " + text1.textRange.characterAttributes.textFont.name + "\
Style:  " + text1.textRange.characterAttributes.textFont.style + "\
Size:  " + text1.textRange.characterAttributes.size + "\
Leading:  " + text1.textRange.characterAttributes.leading + "\
Tracking:  " + text1.textRange.characterAttributes.tracking;
  }
var top = app.selection[0].position[1];
var left = app.selection[0].position[0];
var h = app.selection[0].height;
var w = app.selection[0].width;
var rect1 = app.activeDocument.pathItems.rectangle(top, left, w, h);
rect1.strokeColor = app.activeDocument.swatches["CMYK Cyan"].color;
rect1.strokeWidth = 2.5;
rect1.filled = false;
var rect2 = app.activeDocument.pathItems.rectangle(top, left-200, 200, 200);
rect2.stroked = false;
var text2 = app.activeDocument.textFrames.areaText(rect2);
text2.contents = string;
text2.textRange.characterAttributes.textFont = textFonts["ArialMT"];
text2.textRange.characterAttributes.size = 15;
text2.textRange.fillColor = app.activeDocument.swatches["CMYK Cyan"].color;

Untitled.2021png.png

Likes

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
Reply
Loading...
Sep 22, 2020 0
Community Beginner ,
Sep 22, 2020

Copy link to clipboard

Copied

Thanks so much, that's exactly what I was looking for. Could it also work on selected text rather than the text frame?

Likes

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
Reply
Loading...
Sep 22, 2020 0
Engaged ,
Sep 22, 2020

Copy link to clipboard

Copied

I may be mistaken, but, no, I don't think so. 

Likes

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
Reply
Loading...
Sep 22, 2020 0
Community Beginner ,
Sep 22, 2020

Copy link to clipboard

Copied

Thanks so much, you've been a great help

Likes

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
Reply
Loading...
Sep 22, 2020 0
Engaged ,
Sep 22, 2020

Copy link to clipboard

Copied

Wouldn't you be able to use TextFrame.textSelection?

Likes

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
Reply
Loading...
Sep 22, 2020 1
Engaged ,
Sep 23, 2020

Copy link to clipboard

Copied

You're right, but I think this will only work for a script-targeted and not a user-selected textFrame (although this may not matter if all you have is one textFrame in the document).  Also, while you can get the required properties, I can't think of a way to draw a rectangle around a selected textRange. Again, I may be mistaken though.

Likes

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
Reply
Loading...
Sep 23, 2020 0