Skip to main content
gisteppen
Known Participant
February 16, 2014
Answered

How to insert a new paragraph?

  • February 16, 2014
  • 1 reply
  • 953 views

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

This topic has been closed for replies.
Correct answer 4everJang

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

1 reply

4everJang
4everJangCorrect answer
Legend
February 16, 2014

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

gisteppen
gisteppenAuthor
Known Participant
February 18, 2014

Thanks once again Jang!

Mark