Free Support Forum - aspose.com

Text not displayed in the document after building a table

Hi,


Am using the following code to insert a table to my document and some text after the table. The text is not displayed in the document after the table is rendered.

_builder.MoveToDocumentEnd()

_builder.InsertBreak(BreakType.LineBreak)

Dim pageSetup As PageSetup = _builder.CurrentSection.PageSetup
Dim availableWidth As Double = pageSetup.PageWidth - pageSetup.LeftMargin - pageSetup.RightMargin

_builder.CellFormat.Borders.LineStyle = LineStyle.Single
_builder.CellFormat.Shading.ClearFormatting()

Dim controlTable As Table = _builder.StartTable()

_builder.CellFormat.Width = 100
_builder.InsertCell()
_builder.InsertCheckBox(“chkYes”, False, 11)
_builder.Write(ResourceManager.GetString(“Yes”))

_builder.InsertCell()
_builder.InsertHtml(“This is some text”)
_builder.CellFormat.VerticalMerge = Tables.CellMerge.First
_builder.EndRow()

_builder.InsertCell()
_builder.InsertCheckBox(“chkNo”, False, 11)
_builder.Write(ResourceManager.GetString(“No”))
_builder.InsertCell()
_builder.CellFormat.VerticalMerge = Tables.CellMerge.Previous

Dim documentFormFields As FormFieldCollection = _document.Range.FormFields

If value IsNot Nothing Then

If value Then
documentFormFields(“chkYes” & id).Checked = True
Else
documentFormFields(“chkNo” & id).Checked = True
End If

End If

_builder.EndRow()
_builder.EndTable()

For i As Integer = 0 To 1

Dim cell As Words.Tables.Cell = controlTable.Rows(i).Cells(1)

_builder.MoveTo(cell.FirstParagraph)
cell.CellFormat.Width = availableWidth * 0.8

Next

_builder.InsertBreak(BreakType.LineBreak)

_builder.Writeln()

_builder.ParagraphFormat.ClearFormatting()

_builder.Writeln(“Testing”)

The word testing is never displayed in the document.

Can you please tell me what might be wrong? I’ve attached a sample output document

Thank you.

Hi

Thanks for your request. The problem occurs because after building the table, you move cursor back. To resolve the problem after post-processing, you should move cursor to the end of the document:

For i As Integer = 0 To 1

Dim cell As Cell = controlTable.Rows(i).Cells(1)

_builder.MoveTo(cell.FirstParagraph) ' this is not necessary. you ren remove this to resolve the issue

cell.CellFormat.Width = availableWidth * 0.8

Next

_builder.MoveToDocumentEnd()

_builder.InsertBreak(BreakType.LineBreak)

_builder.Writeln()

_builder.ParagraphFormat.ClearFormatting()

_builder.Writeln("Testing")

Hope this helps.

Best regards,

Thanks Alexey, that change worked.