Skip to main content
Inspiring
September 4, 2020
Question

Reaching Appearance with javascript

  • September 4, 2020
  • 2 replies
  • 884 views

Hi,

 

My main issue right now is that I am making an automation using code only to create a design. I need to change the text appearance but can't seem to access it from the javascript.

 

here's what I got so far :

var Text = docRef.textFrames.getByName('someText').textRange;
Text.fillColor = docRef.swatches.getByName('aColor').color;
Text.strokeColor = docRef.swatches.getByName('anotherColor').color;

and it works if I don't use the appearance pannel but doesn't if I use it to modify the appearance.

Thing is that my fill color need to be over the outline. I can solve that by creating two text overlaying but I was wondering if it was something that can be done without that.

 

as always, thanks for your time and help.

 

This topic has been closed for replies.

2 replies

femkeblanco
Legend
September 4, 2020

You can also apply appearance attributes by applying a graphic style:

 

var Text = app.activeDocument.textFrames["someText"];
app.activeDocument.graphicStyles["graphicStyleName"].applyTo(Text);

 

Inspiring
September 4, 2020

But can I change the order of the outline and fill to make the fill appear over the outline?

femkeblanco
Legend
September 4, 2020

I am unsure what you are trying to achieve, but you can manually create a graphic style where the fill is above the stroke, save it and apply it through a script. 

CarlosCanto
Community Expert
Community Expert
September 4, 2020

is this what you need? this script will add an extra Sroke and Fill to the text Frame and color those, not the characters.

 

var docRef = app.activeDocument;
docRef.selection = null;

var Text = docRef.textFrames.getByName('someText');
Text.selected = true;

app.executeMenuCommand("Adobe New Fill Shortcut");

docRef.defaultFillColor = docRef.swatches.getByName('aColor').color;

app.executeMenuCommand("Adobe New Stroke Shortcut");

docRef.defaultStrokeColor = docRef.swatches.getByName('anotherColor').color;
Inspiring
September 4, 2020

unfortunately no
The script I made already add a stroke to the text if there's none (but in my situation I just need to change its color). Thing is that I am using the appearance panel to put the stroke under the fill. But when I do that the script change an object that appear under the text for some reason.

For now I simply make a text that is the outline and one over it that is the fill. Not ideal but I guess thats what appearance does in the background anyway?

 

Image for reference only (aspect = appearance, fond = fill, contour = outline)