我創建一個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