Copy link to clipboard
Copied
How do I get FrameMaker text into a string using ExtendScript?
#target framemaker
var doc, textRange, text;
// Make variables for the active document and the current text selection.
doc = app.ActiveDoc;
textRange = doc.TextSelection; // TextRange object
text = getText (textRange, doc);
alert (text);
function getText (textObj, doc) {
// Gets the text from the text object.
var textItems, text, count, i;
// Get a list of the strings in the text object or text range.
if (textObj.constructor.name !== "TextRange") {
textItems =
...
Copy link to clipboard
Copied
#target framemaker
var doc, textRange, text;
// Make variables for the active document and the current text selection.
doc = app.ActiveDoc;
textRange = doc.TextSelection; // TextRange object
text = getText (textRange, doc);
alert (text);
function getText (textObj, doc) {
// Gets the text from the text object.
var textItems, text, count, i;
// Get a list of the strings in the text object or text range.
if (textObj.constructor.name !== "TextRange") {
textItems = textObj.GetText (Constants.FTI_String);
}
else {
textItems = doc.GetTextForRange (textObj, Constants.FTI_String);
}
// Concatenate the strings.
text = "";
count = textItems.length;
for (i = 0; i < count; i += 1) {
text += (textItems[i].sdata);
}
return text;
}