I am trying to insert a dynamic table into a .DOC, then save as .PDF. It seems that building a table within a numbered list does not play nice. You will notice that the list above the table loses its numbering.
I have commented out some code, which you can un-comment to see how I have tried to work around this issue. The results are different, but still messed up. I have also tried turning off numbering, and then turning it back on, to no avail.
How do I go about this, so that the table is still in the numbered paragraph, and without throwing off the numbering, or the indent of the table?
.DOC file attached.
Code:
--------------------------------------
Imports Aspose.Words
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim doc As Document = New Document(Server.MapPath("Table Test.doc"))
Dim builder As DocumentBuilder = New DocumentBuilder(doc)
' Move to the bookmark
builder.MoveToBookmark("TestTable")
builder.CellFormat.Borders.LineStyle = LineStyle.Single
builder.CellFormat.FitText = True
' Set the font size
Dim font As Font = builder.Font
font.Size = 8
' This almost works, but loses indent and also removes number.
'builder.ListFormat.RemoveNumbers()
builder.StartTable()
WriteCell(builder, 0.45, "Cell 1")
WriteCell(builder, 0.63, "Another" & vbCrLf & "Cell")
WriteCell(builder, 0.76, "Yet" & vbCrLf & "Another" & vbCrLf & "Cell" & vbCrLf & "Date")
builder.EndRow()
WriteCell(builder, 0.45, "4")
WriteCell(builder, 0.63, "20%")
WriteCell(builder, 0.76, "5/5/2005")
builder.EndRow()
builder.EndTable()
' Delete the bookmark text. Uncomment to see additional behavior of removing bookmark text.
'doc.Range.Bookmarks("TestTable").Text = String.Empty
doc.SaveToPdf(Server.MapPath("Table Test.pdf"))
End Sub
Private Sub WriteCell(ByRef currentBuilder As DocumentBuilder, ByVal width As Double, ByVal cellText As String)
currentBuilder.InsertCell()
currentBuilder.CellFormat.Width = ConvertUtil.InchToPoint(width)
currentBuilder.Write(cellText)
End Sub
End Class