PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Merging cells and border last cell
https://forum.pdfsharp.net/viewtopic.php?f=3&t=4200
Page 1 of 1

Author:  emaborsa [ Sat Nov 14, 2020 10:28 pm ]
Post subject:  Merging cells and border last cell

Hi,
I don't know if I've found a bug or if I am doing something wrong...
I am working with Migradoc library (C# Nuget 1.50.5147).

As an example let's take a table with four columns, where we merge the third and fourth (last) one and add borders to them:
Code:
private static Table BuildTable()
{
    Table table = new Table();

    table.AddColumn(100);
    table.AddColumn(60);
    table.AddColumn(280);
    table.AddColumn(60);

    Row row = table.AddRow();

    Cell cell = row.Cells[0];
    cell.AddParagraph("A");
    SetBorder(cell);

    cell = row.Cells[1];
    cell.AddParagraph("B");
    SetBorder(cell);

    cell = row.Cells[2];
    cell.MergeRight = 1;
    cell.AddParagraph("C");
    SetBorder(cell);

    return table;
}

private static void SetBorder(Cell cell)
{
    cell.Borders.Top.Width = 1;
    cell.Borders.Left.Width = 1;
    cell.Borders.Right.Width = 1;
    cell.Borders.Bottom.Width = 1;
}


The result is that the merged cell does not have the right border:
Attachment:
migra1.png
migra1.png [ 1.43 KiB | Viewed 97 times ]


If I add another column, in order that the merge one is not the last one like followings, it works:

Code:
    // rest of code
    table.AddColumn(60);
    table.AddColumn(60); <-- Added fifth column

    Row row = table.AddRow();

    // rest of code


Is it a bug?

Author:  TH-Soft [ Mon Nov 16, 2020 6:55 am ]
Post subject:  Re: Merging cells and border last cell

emaborsa wrote:
Is it a bug?
I don't know. Setting borders for the forth cell should work with your first implementation.

You can set border width for the table and then you will have borders on all sides - with just one assignment.

Author:  emaborsa [ Thu Nov 26, 2020 2:13 pm ]
Post subject:  Re: Merging cells and border last cell

Thanks, yes it would be another workaround.

I any case, I opened a ticket on Github.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/