有谁知道为什么我的桌子互相重叠?
Dim datatable As PdfPTable = New PdfPTable(4)
Dim page As Rectangle = document.PageSize
datatable.TotalWidth = page.Width - document.LeftMargin - document.RightMargin
datatable.DefaultCell.Border = 0
Dim datatable1 As PdfPTable = New PdfPTable(4)
datatable1.TotalWidth = page.Width - document.LeftMargin - document.RightMargin
datatable1.DefaultCell.Border = 0
Dim datatable2 As PdfPTable = New PdfPTable(4)
datatable2.TotalWidth = page.Width - document.LeftMargin - document.RightMargin
datatable2.DefaultCell.Border = 0
Dim last_pos As Integer = 580
Const xpos As Integer = 70
For i = 0 To extreme_foods.Count - 1
datatable.AddCell(extreme_foods(i))
Next
datatable.WriteSelectedRows(0, -1, xpos, last_pos, writer.DirectContent)
For i = 0 To moderate_foods.Count - 1
datatable1.AddCell(moderate_foods(i))
Next
last_pos = last_pos - datatable1.TotalHeight
datatable1.WriteSelectedRows(0, -1, xpos, last_pos, writer.DirectContent)
For i = 0 To light_foods.Count - 1
datatable2.AddCell(light_foods(i))
Next
last_pos = last_pos - datatable2.TotalHeight
datatable2.WriteSelectedRows(0, -1, xpos, last_pos, writer.DirectContent)
'document.Add(datatable)
Catch de As DocumentException
Console.Error.WriteLine(de.Message)
MessageBox.Show(de.Message)
Catch ioe As IOException
Console.Error.WriteLine(ioe.Message)
MessageBox.Show(ioe.Message)
Catch e As Exception
Console.Error.WriteLine(e.Message)
MessageBox.Show(e.Message)
End Try
document.Close()
即使我减少last_pos
了前一张桌子的高度,它们仍然以一种奇怪的方式重叠,如下所示: