Text Export Script for Adobe Illustrator
This script extracts text contents from all text frames in an Adobe Illustrator document (or multiple documents) and exports the text to a UTF-16 encoded text file. It supports both interactive (using a save dialog) and automatic file naming based on the document’s name.

Description
- Purpose:
Export all text found in text frames of the active document(s) to a text file.
This is useful for extracting content for further processing or backup. - Features:
- Detects the operating system to set the appropriate line feed (Windows or Macintosh).
- If multiple documents are open, it prompts whether to process all files or just the active document.
- Can optionally prompt the user for a save location via a dialog.
- Exports the text with a custom separator and includes header/footer messages in the file.
- Saves the output file using UTF-16 encoding.
- Configuration Options:
useDialog
: Whether to show a save file dialog. (Overrides for multiple file runs)openFile
: Whether to automatically open the exported file after completion.separator
: A text string used to visually separate sections in the output file.
Usage
- Prepare your document(s):
Open one or more Adobe Illustrator files that contain text frames. - Run the Script:
- For a single document:
- If
useDialog
is set totrue
, a save dialog will prompt for a file location. - Otherwise, the file is automatically saved in your Documents folder with the document’s name.
- If
- For multiple documents:
- You will be prompted with a confirmation dialog whether to process all open documents or just the active one.
- The exported text files will be automatically saved in your Documents folder using each document’s name.
- Output:
- The output file(s) will include a header line with a separator, a start message with the document’s name, followed by all text from each text frame, and a footer indicating completion.
- Depending on settings, the file may automatically open after export.
JavaScript
Text Exporter – Illustrator Script (0 downloads )
/*****************************************************************
*
* TextExport 1.3 - by Bramus! - http://www.bram.us/
* Edited by Zujaj Misbah Khan for UTF-16 Text Extraction in Illustrator.
* v 1.x - ????.??.?? - UPD: HTML Output (?)
* v 1.3 - 2008.03.16 - UPD: Base rewrite, now gets all layers (sets & regular ones) in one variable.
* - ADD: Layer Path & Layer Name in export
* - ADD: Cycle Multiple Files
* v 1.2 - 2008.03.11 - User friendly version Added filesave dialog (*FIRST RELEASE*)
* v 1.1 - 2008.03.11 - Extended version, Loops sets too (I can haz recursiveness)
* v 1.0 - 2008.03.11 - Basic version, Loops all layers (no sets though)
*
* Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
*
*****************************************************************/
/**
* CONFIG - CHANGE THESE IF YOU LIKE
* -------------------------------------------------------------
*/
// Use save as dialog (true/false)? - This will be overriden to false when running TextExport on multiple files!
var useDialog = true;
// Open file when done (true/false)? - This will be overriden to true when running TextExport on multiple files!
var openFile = true;
// text separator
var separator = "*************************************";
/**
* NO NEED TO CHANGE ANYTHING BENEATH THIS LINE
* -------------------------------------------------------------
*/
/**
* TextExport Init function
* -------------------------------------------------------------
*/
function initTextExport() {
// Linefeed shizzle
if ($.os.search(/windows/i) != -1)
fileLineFeed = "windows";
else
fileLineFeed = "macintosh";
// Do we have a document open?
if (app.documents.length === 0) {
alert("Please open at least one file", "TextExport Error", true);
return;
}
// Oh, we have more than one document open!
if (app.documents.length > 1) {
var runMultiple = confirm("TextExport has detected Multiple Files.\nDo you wish to run TextExport on all opened files?", true, "TextExport");
if (runMultiple === true) {
docs = app.documents;
} else {
docs = [app.activeDocument];
}
} else {
runMultiple = false;
docs = [app.activeDocument];
}
// Loop all documents
for (var i = 0; i < docs.length; i++) {
// useDialog (but not when running multiple
if ((runMultiple !== true) && (useDialog === true)) {
// Pop up save dialog
var saveFile = File.saveDialog("Please select a file to export the text to:");
// User Cancelled
if (saveFile == null) {
alert("User Cancelled");
return;
}
// set filePath and fileName to the one chosen in the dialog
filePath = saveFile.path + "/" + saveFile.name;
}
// Don't use Dialog
else {
// Auto set filePath and fileName
filePath = Folder.myDocuments + '/' + docs[i].name + '.txt';
}
// create outfile
var fileOut = new File(filePath);
// clear dummyFile
dummyFile = null;
// set linefeed
fileOut.linefeed = fileLineFeed;
fileOut.encoding = "UTF-16";
// open for write
fileOut.open("w", "TEXT", "????");
// Append title of document to file
fileOut.writeln(separator);
fileOut.writeln("* START TextExport for " + docs[i].name);
// Set active document
app.activeDocument = docs[i];
extractText(app.activeDocument, fileOut);
// Hammertime!
fileOut.writeln(separator);
fileOut.writeln("* FINISHED TextExport for " + docs[i].name);
fileOut.writeln(separator);
// close the file
fileOut.close();
// Give notice that we're done or open the file (only when running 1 file!)
if (runMultiple === false) {
if (openFile === true)
fileOut.execute();
else
alert("File was saved to:\n" + Folder.decode(filePath), "TextExport");
}
}
if (runMultiple === true) {
alert("Parsed " + documents.length + " files;\nFiles were saved in your documents folder", "TextExport");
}
}
/**
* TextExtraction
* -------------------------------------------------------------
*/
function extractText(document, fileOut) {
for (var i = 0; i < document.textFrames.length; i++) {
fileOut.writeln('');
fileOut.writeln(document.textFrames[i].contents);
}
}
/**
* TextExport Boot Up
* -------------------------------------------------------------
*/
initTextExport();