iText7 获取 table 高度
iText7 get table height
这是我的代码片段
Dim table As iText.Layout.Element.Table = New iText.Layout.Element.Table(4)
table.SetWidth(pagesize.GetWidth - 40)
Dim something As Paragraph = New Paragraph("LONG TEXT")
Dim cell as Cell = New Cell().Add(New Paragraph("Some Text").SetFont(timesNewRoman))
table.AddCell(cell)
table.AddCell(cell)
table.AddCell(cell)
table.AddCell(cell)
canvas.Add(table.SetMarginLeft(20))
Dim unit as UnitValue = table.GetHeight()
作为table身高,我总是一无所获?我不明白为什么。有没有办法让我得到 table 高度?如果它有所不同,这个 table 在我的页眉中,所以当我想根据放置 table 的位置设置文档页边距时,这样所有文本都放在页眉下方。每次生成此 pdf 时,文本都会有所不同。
Dim result As LayoutResult = table.CreateRendererSubTree().SetParent(doc.GetRenderer()).Layout(New LayoutContext(New LayoutArea(1, New Rectangle(0, 0, 400, 10000.0F))))
tableHeight = result.GetOccupiedArea().GetBBox().GetHeight()
这就是我如何在 itext7 中找到 table 高度的方法,希望它可以帮助别人。
这是我的代码片段
Dim table As iText.Layout.Element.Table = New iText.Layout.Element.Table(4)
table.SetWidth(pagesize.GetWidth - 40)
Dim something As Paragraph = New Paragraph("LONG TEXT")
Dim cell as Cell = New Cell().Add(New Paragraph("Some Text").SetFont(timesNewRoman))
table.AddCell(cell)
table.AddCell(cell)
table.AddCell(cell)
table.AddCell(cell)
canvas.Add(table.SetMarginLeft(20))
Dim unit as UnitValue = table.GetHeight()
作为table身高,我总是一无所获?我不明白为什么。有没有办法让我得到 table 高度?如果它有所不同,这个 table 在我的页眉中,所以当我想根据放置 table 的位置设置文档页边距时,这样所有文本都放在页眉下方。每次生成此 pdf 时,文本都会有所不同。
Dim result As LayoutResult = table.CreateRendererSubTree().SetParent(doc.GetRenderer()).Layout(New LayoutContext(New LayoutArea(1, New Rectangle(0, 0, 400, 10000.0F))))
tableHeight = result.GetOccupiedArea().GetBBox().GetHeight()
这就是我如何在 itext7 中找到 table 高度的方法,希望它可以帮助别人。