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

any idea for areaText vertical align via script

Community Beginner ,
Feb 04, 2024 Feb 04, 2024

 

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
234
Translate
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 ,
Feb 04, 2024 Feb 04, 2024
Translate
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
Participant ,
Feb 05, 2024 Feb 05, 2024
LATEST

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();
}

 

Translate
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