I need to ensure that the DocumentBuilder is in the MainStory (particularly at the end) and not any of the others so that I can insert a page break. How do I move or ensure that the DocumentBuilder's current node/position is in the MainStory?




One of the ways of doing this is using the following code:

Node node = builder.CurrentNode.GetAncestor(typeof(Story));

if(node!=null) {


MessageBox.Show("Current DocumentBuilder node is in the main story.");



builder.CurrentNode can sometimes be null, so a little simpler it will look like this:

Story story = builder.CurrentParagraph.ParentStory;