2
any idea for areaText vertical align via script
Community Beginner
,
/t5/illustrator-discussions/any-idea-for-areatext-vertical-align-via-script/td-p/14401849
Feb 04, 2024
Feb 04, 2024
Copy link to clipboard
Copied
var labelPath = grp.pathItems.rectangle(10, 0, 100, 20);
var labelText = grp.textFrames.areaText(labelPath);
labelText.contents = "label text";
labelText.name = "label";
I want the text to appear in the same place even when I change the font.
Does anyone know how to achieve this while centering text vertically on a path?
TOPICS
Scripting
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explore related tutorials & articles
Community Expert
,
/t5/illustrator-discussions/any-idea-for-areatext-vertical-align-via-script/m-p/14401862#M396246
Feb 04, 2024
Feb 04, 2024
Copy link to clipboard
Copied
check this thread for a possible solution
https://community.adobe.com/t5/illustrator-discussions/vertical-alignment-scripting/td-p/12395365
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Participant
,
LATEST
/t5/illustrator-discussions/any-idea-for-areatext-vertical-align-via-script/m-p/14403092#M396315
Feb 05, 2024
Feb 05, 2024
Copy link to clipboard
Copied
to add to this, here is the function I have been using. allows input for changing to whichever type of alignment. so you can do
AlignAreaText(app.activeDocument.textFrames[0], 1) for center
AlignAreaText(app.activeDocument.textFrames[0], 2) for bottom
etc
/*
Align Area Text Function
aligns an area frame based on an input value, 0=Top, 1=Center, 2=Bottom, 3=Justify
other action string information
The first name is the set name, in a hex based code, first number is number of characters to decode and the second string is the name converted to hex
the second name below actioncount and action, is the action name, same numbers apply, first is character length and second is name converted to hex
*/
function AlignAreaText(TextFrameToAlign, AlignNumber) {
var ActionString = [
'/version 3',
'/name [ 12',
'416c69676e54657874536574',
']',
'/isOpen 1',
'/actionCount 1',
'/action-1 {',
'/name [ 9',
'416c69676e54657874',
']',
'/keyIndex 0',
'/colorIndex 0',
'/isOpen 1',
'/eventCount 1',
'/event-1 {',
'/useRulersIn1stQuadrant 0',
'/internalName (adobe_frameAlignment)',
'/localizedName [ 24',
'417265612054657874204672616d65416c69676e6d656e74',
']',
'/isOpen 0',
'/isOn 1',
'/hasDialog 0',
'/parameterCount 1',
'/parameter-1 {',
'/key 1717660782',
'/showInPalette 4294967295',
'/type (integer)',
'/value ' + AlignNumber,
'}',
'}',
'}'].join("\n")
var f = File(Folder.desktop+"/VerticalTextAlign.aia");
f.open('w');
try {
f.write(ActionString);
} catch (e) {/*alert(e.message)*/}
f.close();
app.executeMenuCommand("deselectall")
TextFrameToAlign.selected = true;
app.loadAction(f);
app.doScript('AlignText', 'AlignTextSet');
try {
app.unloadAction('AlignTextSet', '');
} catch (e) {/*alert(e.message)*/}
f.remove();
}
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

