Skip to main content
Gene Sorg
New Participant
July 25, 2019
Answered

How to add a table after the first paragraph

  • July 25, 2019
  • 1 reply
  • 505 views

I want to add multiple lines of text (each ending with \n) to the first paragraph in a document and then add a table after that. I can create the doc and table but there is only 1 line in the paragraph and the rest of the lines are there but covered up by the table.

     doc = app.ActiveDoc;

     var textLoc, tbl;

     textLoc = new TextLoc (doc,MainFlowInDoc.FirstTextFrameInFlow.FirstPgf, 0);

     doc.AddText (textLoc, multipleLineStringVariable );

     //This works but only shows 1 line in the paragraph which makes sense

     //textLoc = new TextLoc (doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf, 0);

     //My first attempt at using a Constant and this line crashed FrameMaker

     textLoc = new TextLoc (doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf, Constants.FV_OBJ_END_OFFSET);

     // NewTable(format, numCols, numBodyRows, numHeaderRows, numFooterRows, textLoc);

     tbl = doc.NewTable ("Format A", 4, 10, 1, 0, textLoc);

This topic has been closed for replies.
Correct answer frameexpert

Instead of this:

     textLoc = new TextLoc (doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf, Constants.FV_OBJ_END_OFFSET);

use this:

     textLoc = new TextLoc (doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf, Constants.FV_OBJ_END_OFFSET - 1);

1 reply

frameexpert
frameexpertCorrect answer
Brainiac
July 25, 2019

Instead of this:

     textLoc = new TextLoc (doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf, Constants.FV_OBJ_END_OFFSET);

use this:

     textLoc = new TextLoc (doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf, Constants.FV_OBJ_END_OFFSET - 1);

Gene Sorg
Gene SorgAuthor
New Participant
July 25, 2019

Thanks. I also had to remove the "\n" at the end of each line as I stated "multiple lines of text (each ending with \n)". I guess a paragraph only had 1 "\n" by definition. I guess I will have to do a list instead. I am trying to list book and doc processed in the paragraph (one per line):

Book: C:\blah-blah\ES_Samples\SampleBook.book

Doc: C:\blah-blah\ES_Samples\SampleBookTOC.fm

Doc: C:\blah-blah\ES_Samples\SampleFile_UNSTRUCTURED.fm

Doc: C:\blah-blah\ES_Samples\SampleFile_UNSTRUCTURED_2.fm

Doc: C:\blah-blah\ES_Samples\SampleFile_UNSTRUCTURED_3.fm