Copy link to clipboard
Copied
Anyone have code/script for this or know how to create code to extract all the text off an active document in Illustrator. Extract text as in text for any & all text items in the document (TextFrameItem, TextRange, TextPath, etc.). We can just dump the text with alerts().
What I'm not sure of is what order or hierarchy to extract the text. Where do we start from activeDocument.textFrameItems/TextRanges/etc. How are text organized in Illustrator? I'm new to Illustrator scripting.
Something as simple as this may do the trick.
this will act on all open documents.
you could then create a file and write to that rather then just alert
for(var i = 0; i < app.documents.length; i++){
for(var j = 0; j < app.documents.textFrames.length; j++){
var str = app.documents.textFrames
.contents; alert(str);
}
}
Copy link to clipboard
Copied
Something as simple as this may do the trick.
this will act on all open documents.
you could then create a file and write to that rather then just alert
for(var i = 0; i < app.documents.length; i++){
for(var j = 0; j < app.documents.textFrames.length; j++){
var str = app.documents.textFrames
.contents; alert(str);
}
}
Copy link to clipboard
Copied
Thanks, your comment got me to review my script code & fixed some issues below to get it working.
Copy link to clipboard
Copied
Glad I could help.
The documentation is not great.
I find it quite frustrating.
then I try to modify the software here at work and realize that the adobe documentation, While not great, is a hell of a lot better then the completely out of date crap I'm forced to sort through.
Copy link to clipboard
Copied
All the official Guides and References are vague, they have the bare minimum to get anyone started, they could be better, fortunately we have this forum and other pioneers (fellow users) who paved the road for the rest of us.
PageItem is what's called a Super Class, while the objects themselves are Classes. Classes inherit all properties from their parent Super Class, then add properties or methods particular to each individual Class.
Super Classes and Inheritance are very important Javascript concepts (not explained in the guides). One of their major advantages of using them is to avoid creating the same properties and methods for a number of similar objects.
For example (building the js API), if TextFrames, PathItems, PlacedItems, etc, all have Name, GeometricBounds, and Typename properties, instead of creating 3 objects, each with the same 3 properties (9 properties total), it is more convenient to create a super class PageItem, add these 3 properties, then create our 3 classes based on it that will share the same properties....then, continue adding properties particular to each class, like TextFrame.contents, PathItem.area, or PlacedItem.file
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more