iTextsharp - draw a line at the end and start of a page with tables

后端 未结 2 1932
無奈伤痛
無奈伤痛 2021-01-29 02:54

Selecting records from a table I create iTextsharp\'s Tables one for every first letter of the records

On the picture a table for the \"G\" letter:

\"G\" is a ro

相关标签:
2条回答
  • 2021-01-29 03:34

    This should be helpful for you: itextsharp: how to show the bottom line of a table with property HeaderRows=1 if border bottom of the row is not set?

    You will need to add some code to draw an additional header line, too e.g.:

    columns = widths[0].Length - 1;
    rect = new Rectangle(widths[0][0], heights[0], widths[0][columns], heights[0]);
    rect.BorderColor = Color.BLACK;
    rect.BorderWidth = 1;
    rect.Border = Rectangle.TOP_BORDER;
    canvases[PdfPTable.BASECANVAS].Rectangle(rect);
    

    4.1.6.0

    0 讨论(0)
  • 2021-01-29 03:51

    I found the solution, no new class required

    Dim heightActualLetter, verticalSpaceAvailable As Integer
    heightActualLetter = table.TotalHeight
    verticalSpaceAvailable = pdfWrite.GetVerticalPosition(False) - pdfDoc.BottomMargin
    If heightActualLetter > verticalSpaceAvailable Then
    
        Dim finalLine As PdfContentByte
        finalLine = pdfWrite.DirectContent
    
        Dim curY As Int32
        curY = pdfWrite.GetVerticalPosition(False)
    
        finalLine.SetLineWidth(0.5)
        finalLine.MoveTo(xStart, curY)
        finalLine.LineTo(xEnd + 1, curY)
        finalLine.Stroke()
    End If
    

    I don´t know why I need the +1 on xEnd + 1 but maybe is because of the other lines being 0.5 I need to rounded up

    0 讨论(0)
提交回复
热议问题