PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

Table header borders render incorrectly

Open gregbrant2 opened this issue 3 years ago • 0 comments

I'm trying to set borders on the inner edges of a table but the border renders incorrectly on the last edge of the last header cell.

There's a repro here which produces the following output. Note the right border on the last cell in the first row.

image

I'm trying to track this down myself, so far I've found that the right border Borders.Right has a Name of "Left" on that last cell, so I presume something somewhere is munging the borders, but I can't see where, I've put breakpoints in the setters of Cell.Borders and Borders.Right but they don't appear to be getting set anywhere unexpeced (i.e. by something other than my code).

If I change the implementation of TableRenderer.RenderHeaderRows() as follows as and add a breakpoint as indicated

    void RenderHeaderRows()
    {
      if (this.lastHeaderRow < 0)
        return;

      for (var index = 0; index < this.mergedCells.Count; index++)
      {
        Cell cell = this.mergedCells[index];
        var name = cell.Borders.Right.Name; // Breakpoint here
        if (cell.Row.Index <= this.lastHeaderRow)
          RenderCell(cell);
      }
    }

and a breakpoint in Borders.GetMyName() I can see it is indeed matching the left border by hash code:

image

and here showing the call through Right.Name image

... I'm still looking into this but posting this issue in case anyone has any pointers.

Presumably either:

  • something is setting the Left of this last cell based on the Right of the previous cell, or
  • there's a little bit of derp somewhere accidentally setting the right = left but I can't see this anywhere using Find All References etc.
  • something else.

gregbrant2 avatar Apr 07 '21 08:04 gregbrant2