Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the border color of a cell bricks SetEdge() #228

Open
Neralem opened this issue Jan 20, 2025 · 0 comments
Open

Setting the border color of a cell bricks SetEdge() #228

Neralem opened this issue Jan 20, 2025 · 0 comments
Labels
investigation Under investigation

Comments

@Neralem
Copy link

Neralem commented Jan 20, 2025

I can use Table.SetEdge(...) to modify the edges of a range of cells. This wont work if I set the border color of a cell.

Image

Take a look at this test code:

using System.Diagnostics;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;

Document document = new();

Section section = document.AddSection();

#region Table 1   -   All good
Table table = section.AddTable();
table.Borders.Visible = true;

table.AddColumn(Unit.FromCentimeter(2));
table.AddColumn(Unit.FromCentimeter(2));
table.AddColumn(Unit.FromCentimeter(2));
table.AddColumn(Unit.FromCentimeter(2));

table.AddRow()[0].AddParagraph("Test");
table.AddRow()[1].AddParagraph("Test");
table.AddRow()[2].AddParagraph("Test");
table.AddRow()[3].AddParagraph("Test");

table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Interior, BorderStyle.None, 0);
#endregion

section.AddParagraph();

#region Table 2   -   If I color the table, SetEdge wont work properly
Table table2 = section.AddTable();
table2.Borders.Visible = true;

table2.AddColumn(Unit.FromCentimeter(2));
table2.AddColumn(Unit.FromCentimeter(2));
table2.AddColumn(Unit.FromCentimeter(2));
table2.AddColumn(Unit.FromCentimeter(2));

table2.AddRow()[0].AddParagraph("Test");
table2.AddRow()[1].AddParagraph("Test");
table2.AddRow()[2].AddParagraph("Test");
table2.AddRow()[3].AddParagraph("Test");


Color c = Color.Parse("#00FF00");

foreach (Row r in table2.Rows.OfType<Row>())
{
    foreach (Cell cell in r.Cells.OfType<Cell>())
    {
        cell.Borders.Color = c;
    }
}

table2.SetEdge(0, 0, table2.Columns.Count, table2.Rows.Count, Edge.Interior, BorderStyle.None, 0);
#endregion


PdfDocumentRenderer pdfRenderer = new() { Document = document };
pdfRenderer.RenderDocument();
using FileStream outputStream = new("output.pdf", FileMode.Create);
pdfRenderer.PdfDocument.Save(outputStream);

Expected Behavior

The second Table should have only outline borders like the first table but in green.

Actual Behavior

The second table has partially removed interior borders. Some in black and only some in green.

Steps to Reproduce the Behavior

  • Create a new .Net 8 Console App
  • Install nuget package PDFsharp-MigraDoc v6.1.1
  • Insert & run the given code
  • Take a look at output.pdf
@Neralem Neralem changed the title Settings the border color of a cell bricks SetEdge() Setting the border color of a cell bricks SetEdge() Jan 21, 2025
@ThomasHoevel ThomasHoevel added the investigation Under investigation label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation Under investigation
Projects
None yet
Development

No branches or pull requests

2 participants