Skip to main content
Participating Frequently
June 1, 2023
Answered

Is there a way to delete all my overset text at once?

  • June 1, 2023
  • 3 replies
  • 1388 views

As mentioned above, i have a huge document with multiple overset (and unwanted) text all around, i want to clean it up and dont want to go one by one.... maybe a script? Thank you !!

This topic has been closed for replies.
Correct answer m1b

Okay @Lalo Mc. Fly, after accidentally writing the script for Indesign (*facepalm*) here is my attempt at the same script for Illustrator. Let me know if any bugs, and ideally post a sample document that shows the bug.

- Mark

 

 

/**
 * Remove All Overset Text In Active Document For Illustrator
 * @author m1b
 * @discussion https://community.adobe.com/t5/illustrator-discussions/is-there-a-way-to-delete-all-my-overset-text-at-once/m-p/13832918
 */
(function () {

    var doc = app.activeDocument,
        stories = doc.stories,
        counter = 0;

    for (var i = stories.length - 1; i >= 0; i--) {

        var story = stories[i],
            lastTextFrame = story.textFrames[story.textFrames.length - 1];

        // point text can't be overset
        if (lastTextFrame.kind == TextType.POINTTEXT)
            continue;

        // make a temp frame to take the overset text, if any
        var temp = doc.textFrames.areaText(doc.pathItems.rectangle(0, 0, 3000, 3000));
        lastTextFrame.nextFrame = temp;
        var over = temp.characters;

        // remove the overset text
        if (over.length && counter++)
            for (var j = 0; j < over.length; j++)
                story.characters[story.characters.length - 1].remove();

        // clean up
        temp.remove();

    }

    alert('Removed ' + counter + ' overset texts.');

})();

 

 

3 replies

Kurt Gold
Community Expert
Community Expert
June 1, 2023

It may also work by selecting all (area) type objects, converting them to point type objects in the Type menu (a warning message should appear then, informing that you are going to clear all overset text with that step) and then converting the point type objects back to area type objects.

 

m1b
Community Expert
Community Expert
June 1, 2023

Cool approach Kurt! that would be super quick and convenient in most cases but if you have overset text on a path you may need my script.

- Mark

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
June 1, 2023

Okay @Lalo Mc. Fly, after accidentally writing the script for Indesign (*facepalm*) here is my attempt at the same script for Illustrator. Let me know if any bugs, and ideally post a sample document that shows the bug.

- Mark

 

 

/**
 * Remove All Overset Text In Active Document For Illustrator
 * @author m1b
 * @discussion https://community.adobe.com/t5/illustrator-discussions/is-there-a-way-to-delete-all-my-overset-text-at-once/m-p/13832918
 */
(function () {

    var doc = app.activeDocument,
        stories = doc.stories,
        counter = 0;

    for (var i = stories.length - 1; i >= 0; i--) {

        var story = stories[i],
            lastTextFrame = story.textFrames[story.textFrames.length - 1];

        // point text can't be overset
        if (lastTextFrame.kind == TextType.POINTTEXT)
            continue;

        // make a temp frame to take the overset text, if any
        var temp = doc.textFrames.areaText(doc.pathItems.rectangle(0, 0, 3000, 3000));
        lastTextFrame.nextFrame = temp;
        var over = temp.characters;

        // remove the overset text
        if (over.length && counter++)
            for (var j = 0; j < over.length; j++)
                story.characters[story.characters.length - 1].remove();

        // clean up
        temp.remove();

    }

    alert('Removed ' + counter + ' overset texts.');

})();

 

 

Participating Frequently
June 1, 2023

Script works perfectly, thank you so much Mark !

m1b
Community Expert
Community Expert
June 1, 2023

You're welcome!

m1b
Community Expert
Community Expert
June 1, 2023

EDIT: Sorry! On my phone I couldn't see which forum this was posted in and I assumed it was Indesign. Please ignore this answer because it is a script for Indesign.

 

Hi @Lalo Mc. Fly, here's a script that should do this. I just wrote it now, so it's quite untested, so have a careful look through your document after using it.

- Mark

 

 

 

/**
 * Remove All Overset Text In Active Document for Indesign
 * @author m1b
 * @discussion https://community.adobe.com/t5/illustrator-discussions/is-there-a-way-to-delete-all-my-overset-text-at-once/m-p/13832918
 */
function main() {

    var doc = app.activeDocument,
        stories = doc.stories.everyItem().getElements(),
        counter = 0;

    for (var i = stories.length - 1; i >= 0; i--) {

        if (stories[i].overflows == false)
            continue;

        var lastTextFrame = stories[i].textContainers[stories[i].textContainers.length - 1];
        var overFlowText = stories[i].characters.itemByRange(lastTextFrame.texts[0].insertionPoints[-1], stories[i].insertionPoints[-1]);

        if (overFlowText.isValid) {
            overFlowText.remove();
            counter++;
        }

    }

    alert('Removed ' + counter + ' overset texts.');

};

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Remove All Overset Text');

 

 

CarlosCanto
Community Expert
Community Expert
June 1, 2023

Hi Mark, is that script for InDesign?

m1b
Community Expert
Community Expert
June 1, 2023

Oops! Haha. Yep, on my phone I didn't notice it was for Illustrator!