Hi Brandon,
Thanks for your inquiry. I have worked with your sample application and have found that you are creating one big table. Please insert an empty paragraph after creating each table. I have modified your code. Please check the following highlighted code snippet. I have attached the complete code with this post for your kind reference.
Hope this helps you. Please let us know if you have any more queries.
Private Sub addDisciplineAndResults(s As Section)
Dim para = s.NewParagraph
para.NewText("Mammalian Serology", size:=9, bold:=True)
para.AddBlankLine()
'Add Animals
For a As Integer = 0 To 25 - 1
Dim table = s.NewTable
'Add heading
Dim rowHeading = table.NewRow
rowHeading.NewCell().NewText("Specimen", size:=9, bold:=True)
rowHeading.NewCell().NewText("Test Name", size:=9, bold:=True)
rowHeading.NewCell().NewText("Result", size:=9, bold:=True)
rowHeading.RowFormat.Borders.LineStyle = LineStyle.None
Dim rowAnimal = table.NewRow
Dim aFirstCell = rowAnimal.NewCell()
aFirstCell.NewText(a & "-14 Avain - Galliform / poultry - Checken - Unknown - Juvenile", size:=9)
rowAnimal.NewCell()
Dim lastAnimalCell = rowAnimal.NewCell()
SpanCellsInRow(aFirstCell, lastAnimalCell)
For sp As Integer = 0 To 5 - 1
Dim rowSpecimen = table.NewRow
Dim sFirstCell = rowSpecimen.NewCell()
sFirstCell.NewText("Liver - " & sp, size:=9)
rowSpecimen.NewCell().NewText("Test A", size:=9)
rowSpecimen.NewCell().NewText("Approximately 500 ppm", size:=9)
Dim rowSpecimenTestB = table.NewRow
rowSpecimenTestB.NewCell()
rowSpecimenTestB.NewCell().NewText("Test B", size:=9)
rowSpecimenTestB.NewCell().NewText("Negative", size:=9)
Dim rowSpecimenTestC = table.NewRow
rowSpecimenTestC.NewCell()
rowSpecimenTestC.NewCell().NewText("Test C", size:=9)
rowSpecimenTestC.NewCell().NewText("> 0 = ayz", size:=9)
Next
para = s.NewParagraph()
'KeepTableFromPageBreak(table)
Next
End Sub
Public Sub New()
Doc = New Document
' Builder = New DocumentBuilder
Dim currentSection As Section = Doc.FirstSection
currentSection.PageSetup.BottomMargin = InchToPoint(0.5)
currentSection.PageSetup.TopMargin = InchToPoint(0.5)
currentSection.PageSetup.LeftMargin = InchToPoint(0.5)
currentSection.PageSetup.RightMargin = InchToPoint(0.5)
buildHeader(currentSection)
addReportTypeBar(currentSection)
addAddressWindow(currentSection)
addAssociatedParties(currentSection)
addAnimalInformation(currentSection)
addLabFindings(currentSection)
Doc.UpdateTableLayout()
Doc.UpdatePageLayout()
For Each table As Table In Doc.GetChildNodes(NodeType.Table, True)
For Each cell As Cell In table.GetChildNodes(NodeType.Cell, True)
For Each para As Paragraph In cell.Paragraphs
If Not (cell.ParentRow.IsLastRow AndAlso para.IsEndOfCell) Then
para.ParagraphFormat.KeepWithNext = True
End If
Next para
Next cell
Next
SaveAndOpenPDF()
SaveAndOpenDocx()
End Sub