Cannot insert requested break inside a table

Hi Please find my code below. I am getting the error message as “Cannot insert the requested break inside a table.”

Could you please suggest solution.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim myPage As New CMSPage(CInt(Request("Pageid")))

Dim myDoc As New Aspose.Words.Document()

Dim builder As New DocumentBuilder(myDoc)

AsposeHelper.Words.SetLicense()

PrintChildPages(myPage, builder, currentlevel, 0)

myDoc.Save(myPage.Name.ToString & ".doc", SaveFormat.Doc, SaveType.OpenInWord, Response)

End Sub

Private Sub PrintChildPages(ByVal page As CMSPage, ByVal builder As DocumentBuilder, ByVal prevLevel As String, ByVal childlevel As Integer)

builder.StartTable()

builder.RowFormat.Height = 100

Dim layoutXml As XmlDocument = bwAE.Xml.parse(page.Layout.Structure)

If childlevel = 0 Then

builder.Write(prevLevel & ". " & page.Name.Value)

Else

builder.Write(prevLevel & "." & childlevel & ". " & page.Name.Value)

End If

builder.InsertBreak(BreakType.LineBreak)

For Each node As XmlNode In layoutXml.SelectNodes("/root/row")

For Each el As XmlNode In node.SelectNodes("content")

builder.InsertCell()

Dim cellformat As Aspose.Words.Tables.CellFormat = builder.CellFormat

cellformat.Width = 510

cellformat.LeftPadding = 30

cellformat.RightPadding = 30

cellformat.TopPadding = 30

Dim sectionID As Integer = bwAE.Xml.intAttribute(el, "id")

If Not String.IsNullOrEmpty(page.Content(sectionID).Content.ToString) Then

builder.InsertHtml(page.Content(sectionID).Content)

End If

builder.EndRow()

Next

Next

builder.EndTable()

If page.Children.Count > 0 Then

childlevel = childlevel + 1

For Each childpage As CMSPage In page.Children

PrintChildPages(childpage, builder, currentlevel, childlevel)

Next

End If

End Sub

Hi
Thanks for your request. I can’t reproduce the issue on my side. Could you please simplify your code? I tried to reproduce the problem using the following code:

Dim doc As Document = New Document()
Dim builder As DocumentBuilder = New DocumentBuilder(doc)
builder.StartTable()
builder.RowFormat.Height = 100
builder.InsertBreak(BreakType.LineBreak)
For i As Integer = 0 To 5
For j As Integer = 0 To 5
builder.InsertCell()
builder.Write("test")
Next
builder.EndRow()
Next
builder.EndTable()
doc.Save("C:\Temp\out.doc")

Best regards,