Copy link to clipboard
Copied
I want to insert a paragraph with something like a line, to separate hunks of text I am pasting into a document. I see no obvious way to do this. I see no AddPgf() function, for example. And no Doc.AddPgf() or whatever.
I can add text in an existing paragraph with this:
function test1() {
var doc = app.ActiveDoc;
var t1 = new TextLoc();
var firstPgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
t1.obj = firstPgf;
t1.offset = 0;
doc.AddText (t1, "Hello");
}
I had the idea that I would do AddText() at the very end of a paragraph to create a new paragraph, but this code crashes FrameMaker (only difference from above is Constants.FV_OBJ_END_OFFSET):
function test1() {
var doc = app.ActiveDoc;
var t1 = new TextLoc();
var firstPgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
t1.obj = firstPgf;
t1.offset = Constants.FV_OBJ_END_OFFSET;
doc.AddText (t1, "Hello");
}
Thanks,
Mark
Hi Mark,
You need to use the NewSeriesPgf method of the document object. Then create a TextLoc on the new pgf and add text.
var newPgf = doc.NewSeriesPgf ( oldPgf );
var TLoc = new TextLoc ( newPgf, 0 );
doc.AddText ( TLoc, "This is a new paragraph" );
Good luck
Jang
Copy link to clipboard
Copied
Hi Mark,
You need to use the NewSeriesPgf method of the document object. Then create a TextLoc on the new pgf and add text.
var newPgf = doc.NewSeriesPgf ( oldPgf );
var TLoc = new TextLoc ( newPgf, 0 );
doc.AddText ( TLoc, "This is a new paragraph" );
Good luck
Jang
Copy link to clipboard
Copied
Thanks once again Jang!
Mark