我创建一个PDF表格,我可以管理时张贴在这里表需要一个以上的页面会发生什么:手柄或拦截新的页面事件划清界限
iTextsharp - draw a line at the end and start of a page with tables
如果表格需要另一个页面,那么我在插入新页面之前在实际页面上绘制最后一行。
现在我需要在NEW页面上画一条顶部线条,但我不知道是哪个方法调用。我试图这样:
Imports iTextSharp.text.pdf
Public Class LineaBottom
Implements IPdfPTableEvent
Public Sub TableLayout(table As PdfPTable, widths As Single()(), heights() As Single, headerRows As Integer, rowStart As Integer, canvases() As PdfContentByte) Implements IPdfPTableEvent.TableLayout
'Throw New NotImplementedException()
Dim columns As Integer
Dim footer As Integer = widths.Length - table.FooterRows
Dim header As Integer = table.HeaderRows - table.FooterRows + 1
Dim ultima As Integer = footer - 1
If last <> -1 Then
Dim line As PdfContentByte
line = pdfWrite.DirectContent
line.SetLineWidth(0.5)
line.MoveTo(xStart, curY)
line.LineTo(xEnd, curY)
line.Stroke()
'canvases(PdfPTable.BASECANVAS).Rectangle(rect)
End If
End Sub
End Class
其中xStart和xEnd是全局变量,左边距和右边距加上或减去一个值。
我不知道如何去适应行
canvases(PdfPTable.BASECANVAS).Rectangle(rect)
,因为该行是从Java样本绘制一个矩形,我只需要一条线
和线
If last <> -1 Then
检测到页面的最后一行,我需要检测新页面的第一行
感谢您的支持。我靠近找到解决方案。如果我使用Dim cb As PdfContentByte,然后cb = canvases(PdfPTable。BASECANVAS)如果首先使用“Dim myCanvas As New Canvas()”,则会出现“画布未声明”的错误,并且在https://msdn.microsoft.com/zh-cn/library/ms745163(v = vs.110).aspx?cs-save-lang = 1&cs-lang = vb#code-snippet-1我是否需要导入或声明之前的某些内容? – fedeteka