Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Get FrameMaker Text as a String

Community Expert ,
Mar 15, 2024 Mar 15, 2024

How do I get FrameMaker text into a string using ExtendScript?

TOPICS
Scripting
295
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 15, 2024 Mar 15, 2024
#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 = 
...
Translate
Community Expert ,
Mar 15, 2024 Mar 15, 2024
LATEST
#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;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines