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