Skip to main content
Participating Frequently
September 25, 2023
Question

Create Outline all texts, just not the variable texts

  • September 25, 2023
  • 4 replies
  • 498 views
I want to convert (Create Outline) all texts but the variable texts should not be converted.
All text is in one layer. Is this possible with javascript?

 

This topic has been closed for replies.

4 replies

Ton Frederiks
Community Expert
Community Expert
September 25, 2023

If you want the text outlined in a PDF, you can put your text on a layer with the Outline Object effect applied to the layer.

The text will be editable in Illustrator but outlined in the PDF.

Kurt Gold
Community Expert
Community Expert
September 25, 2023

Just to verify, if you say "variable texts", do you mean text variables in the Variables palette (as Carlos assumed) or do you perhaps mean type objects that involve variable fonts?

 

CarlosCanto
Community Expert
Community Expert
September 25, 2023

yeah it should be possible to do that manually or with Javascript

 

- select all variables in the Variables panel

- click on Select All Bound Objects in the Variables panel Flyout menu

- press Ctrl+2 to lock Variable text frames

- press Ctrl+A to select all

- press Ctrl+Shift+O to Create Outlines, I don't remember if this is default or my own shortcut, if it didn't work, go to Type->Create Outlines

Participating Frequently
September 26, 2023
Yes, CarlosCanto, I tried to do what you said. The code I wrote works, but I was able to select the variables this way.
How can you write this better?

 

var refDoc = app.activeDocument;
covertAllText();
function covertAllText() {
    for (var i = 0; i < refDoc.pageItems.length; i++) {
        if (String(refDoc.pageItems[i].contentVariable).lastIndexOf("lid") > 0) {
            var item = refDoc.pageItems[i];
            item.selected = true;
            app.executeMenuCommand('lock');
        }
        if (String(refDoc.pageItems[i].contentVariable).lastIndexOf("tub") > 0) {
            var item = refDoc.pageItems[i];
            item.selected = true;
            app.executeMenuCommand('lock');
        }
    }
    app.executeMenuCommand('Text Objects menu item');
    app.executeMenuCommand('outline');
    app.executeMenuCommand('unlockAll');
    app.executeMenuCommand('deselectall');
}

 

 

CarlosCanto
Community Expert
Community Expert
September 26, 2023

I would only process the Variables instead of all the text items, it'll make a difference if you have lots of text frames

// outline all text except variables
// https://community.adobe.com/t5/illustrator-discussions/create-outline-all-texts-just-not-the-variable-texts/m-p/14112406#M381852

var refDoc = app.activeDocument;
covertAllText();

function covertAllText() {
    var vars, v, arr = [];
    
    vars = refDoc.variables;
    
    // process Variables instead of all text items
    for (var a=0; a<vars.length; a++) {
        v = vars[a];

        // collect only text variables, ignore visibility and other kind of variables
        if (v.kind == "VariableKind.TEXTUAL") {
            for (var b=0; b<v.pageItems.length; b++) { // in case two or more items have the same variable name
                arr.push(v.pageItems[b]);
            }
        }
    }

    // lock variable text frames
    for (var c=0; c<arr.length; c++) {
        arr[c].locked = true;
    }

    app.executeMenuCommand('Text Objects menu item');
    app.executeMenuCommand('outline');
    app.executeMenuCommand('unlockAll');
    app.executeMenuCommand('deselectall');
}
Monika Gause
Community Expert
Community Expert
September 25, 2023

Is it one single text object?

You might need to describe your situation more detailed.