Null Value of builder.CurrentNode can "moveTo" settings a problem here?

Hello,I have a problem in finding the current Position of the builder with builder.CurrentNode call.This is what I am trying to do.

I am dynmaically building the table with a builder.

I am inserting a row of normal text and richtext of two cells in one row.

I have inserted my noraml text and now:
Current builder node position is searched after inserting a second cell into a row.

//insert cell

builder.InsertCell();

InsertDocument(builder.CurrentNode, rtfDoc);

//builder.CurrentNode is null and valid rtf.

fails here because insertAfterNode is null

if (!((insertAfterNode.NodeType == NodeType.Paragraph) || (insertAfterNode.NodeType == NodeType.Table)))

Do I have to use moveTo on documentBuilder object before the Current node is found.

Thank You

Andrew

Andrew,

It seems like CurrentNode gets null after calling InsertCell indeed. I will find out if this is a bug and let you know immediately.

Actually, this does not seem to be a bug. As it is stated in Aspose.Words API reference, CurrentNode is a cursor of DocumentBuilder and points to a Node that is a direct child of a Paragraph. In your case you do not insert a paragraph to the cell so that's why CurrentNode is null. Avoid the use of CurrentNode then. What if you explicitly create an empty paragraph, insert it to the cell and then pass it to InsertDocument, like this:

builder.StartTable();

builder.InsertCell();

Paragraph paragraph = new Paragraph(builder.Document);

builder.InsertNode(paragraph);

InsertDocument(paragraph, rtfDoc);

Will it work? Please try it and let me know.

Quick amendment: sorry, InsertNode is not applicable here, it only works with text level nodes. The correct implementation is:

Paragraph paragraph = builder.InsertParagraph();

Hello DmitryV, I have recieved a exeception on trying to end the table I can processes the rtf no problem and when I call builder.EndTable() it brings up an exception of

"cannot end table in this state". Is there a clue to this?

Here I am using

public void InsertRtf(Document suppDoc, DocumentBuilder builder, string rtf)

MemoryStream stream = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(rtf));

Document rtfDoc = new Document(stream);

Paragraph paragraph = builder.InsertParagraph();

InsertDocument(paragraph, rtfDoc);

////==============

builder.EndTable();

Is there manipulation of state being performed here,and what are the states that cause an exception?

Thank You

Andrew

Andrew,

Please try calling EndRow before you call EndTable. If this does not help, send me the entire code snippet or even a zipped sample project to let me reproduce the issue completely.