I want to add marker to all H1 headings in a FrameMaker document
I want to grab the heading text and add it as a marker to all the respective H1 headings in my FrameMaker document. I am using the following script but it gives me an error and FM crashes after adding the marker.
Also, this is adding only a fixed text as a marker:
var doc = app.ActiveDoc;
var flow = doc.MainFlowInDoc;
var tframe = flow.FirstTextFrameInFlow;
var pgf = tframe.FirstPgf;
var target1 = doc.GetNamedObject(Constants.FO_PgfFmt, "h1");
while (pgf.ObjectValid()) {
if (pgf.Name == target1.Name) {
createMarker (doc, pgf, 0, "newlink h1", "");
}
pgf = pgf.NextPgfInDoc;
}
function createMarker(doc, pgf, offset, type, text) {
var tLoc = new TextLoc(pgf, offset);
var marker = doc.NewAnchoredObject(Constants.FO_Marker, tLoc);
var markerType = doc.GetNamedObject(Constants.FO_MarkerType, type);
marker.MarkerTypeId = markerType;
marker.MarkerText = text;
return 1;
}Please help.
