0
getting text(s) of element
Community Beginner
,
/t5/framemaker-discussions/getting-text-s-of-element/td-p/10658287
Oct 09, 2019
Oct 09, 2019
Copy link to clipboard
Copied
Hi,
does anybody know how can I get the text(s - for nested element ) of framemaker elements.
example
var doc = app.ActiveDoc
var root = doc.MainFlowInDoc.HighestLevelElement
how to get the text of the root ?
thanks
TOPICS
Scripting
,
Structured
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Mentor
,
/t5/framemaker-discussions/getting-text-s-of-element/m-p/10658486#M62875
Oct 09, 2019
Oct 09, 2019
Copy link to clipboard
Copied
Hi andranika,
Here is a function I use to get the text of an element. It only works for container and table cell elements, not markers, xrefs, etc. Hope this helps.
//if you want to preserve pgf marks with some sort of character (\n, etc.)
//send it for pgfMarkSubstitution, otherwise send an empty string.
function elem_GetElementText(doc, elem, pgfMarkSubstitution)
{
var text = "";
if(!doc.ObjectValid()) doc = app.ActiveDoc;
if(!doc.ObjectValid()) return "";
if(!elem.ObjectValid()) return "";
var tr = new TextRange();
if(elem.ElementType == Constants.FV_FO_TBL_CELL)
{
tr.beg.obj = elem.Object.FirstPgf;
tr.beg.offset = 0;
tr.end.obj = elem.Object.FirstPgf;
tr.end.offset = Constants.FV_OBJ_END_OFFSET;
}
else tr = elem.TextRange;
//doc.TextSelection = tr;
//return "";
var ti = doc.GetTextForRange(tr, Constants.FTI_String | Constants.FTI_PgfEnd);
for(var i = 0; i < ti.len; i++)
{
if(ti[i].dataType == Constants.FTI_PgfEnd && pgfMarkSubstitution != "")
text += pgfMarkSubstitution;
else if(ti[i].dataType == Constants.FTI_String)
text += ti[i].sdata;
}
return text;
}
Russ
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Beginner
,
/t5/framemaker-discussions/getting-text-s-of-element/m-p/10668543#M62936
Oct 14, 2019
Oct 14, 2019
Copy link to clipboard
Copied
Hello
On my side i have got this function when i work with the HLE (hightest level element)
doc = app.ActiveDoc;
var root=GetFirstElement(doc);
tag = root.ElementDef.Name;
$.writeln(" HLE="+tag);
if (tag=="ABC"){
// Do something;
alert ("test ok");
}
function GetFirstElement(doc) {
var doc, flow, root,tag,attrs;
//doc = app.ActiveDoc;
flow = doc.MainFlowInDoc;
root = flow.HighestLevelElement;
return root;
}
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Mentor
,
/t5/framemaker-discussions/getting-text-s-of-element/m-p/10675671#M63019
Oct 17, 2019
Oct 17, 2019
Copy link to clipboard
Copied
Hi, are you asking another question? If you are, I do not know what the question is.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Beginner
,
LATEST
/t5/framemaker-discussions/getting-text-s-of-element/m-p/10675688#M63023
Oct 17, 2019
Oct 17, 2019
Copy link to clipboard
Copied
it wasn't a question but just how i manage the HLE in my script.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

