Problem with styling PdfGrid

I found an example for styling the borders of a PdfGrid in the Syncfusion Support Forum (TableSample-1353788781), which I modified for my needs. It should remove the bottom border of the 1st header and the to border of the second header. This worked fine (first part of attached file). I noticed that this program used Syncfusion.Compression.Base and Syncfusion.Pdf.Base.

When I inserted this code in my actual project (see attached file), it did not work properly. All borders from header1 and header2 were removed. Both programs should be identical. In my actual program I use Blazor, Net8 and Syncfusion.Pdf.Net.Core 26.2.4.

Can you please provide a working sample for customizing the bottom and top borders alone of a PdfGrid?


Hartmut


Attachment: File_TableSample_396cf10a.docx

4 Replies

IJ Irfana Jaffer Sadhik Syncfusion Team June 4, 2025 12:52 PM UTC

Hi Hartmut,


Currently we are analyzing the reported behavior with the provided details on our end and we will share the further details on June 9th, 2025.


Regards,

Irfana J.



AG Aribalakrishnan Govindasamy Syncfusion Team June 9, 2025 02:23 PM UTC

Hi Hartmut,

We confirmed the issue "Preservation issues with PdfGrid Styling" as a defect in our product, and we will include the fix into our upcoming weekly NuGet release, which will be available on June 24th,2025.

Please use the below feedback link to track the status of the reported bug.

Note: If you require a patch for the reported issue in any of our Essential Studio Main or SP release version, then kindly let us know the version, so that we can provide a patch in that version based on our SLA policy.

Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors, including but not limited to QA checks and work reprioritization.”

Regards,


IJ Irfana Jaffer Sadhik Syncfusion Team June 17, 2025 11:59 AM UTC

Hi Hartmutt,


Sorry for the inconvenience caused.
Upon further analysis of your reported requirements, we have updated the code snippet accordingly. The updated version should help you achieve the desired functionality within the sample.
Please refer to the following modified code snippet:

 

PdfDocument doc = new PdfDocument();

// Add a page

PdfPage page = doc.Pages.Add();

// Create a PdfGrid

PdfGrid pdfGrid = new PdfGrid();

pdfGrid.Columns.Add(3);

pdfGrid.Headers.Add(2);

// First header row - merged across all columns

pdfGrid.Headers[0].Cells[0].ColumnSpan = 3;

pdfGrid.Headers[0].Cells[0].Value = "Name";

// Second header row

pdfGrid.Headers[1].Cells[0].Value = "Name2";

pdfGrid.Headers[1].Cells[1].Value = "Age2";

pdfGrid.Headers[1].Cells[2].Value = "Gender2";

// Add rows

PdfGridRow row1 = pdfGrid.Rows.Add();

row1.Cells[0].Value = "abc";

row1.Cells[1].Value = "21";

row1.Cells[2].Value = "Male";

PdfGridRow row2 = pdfGrid.Rows.Add();

row2.Cells[0].Value = "def";

row2.Cells[1].Value = "23";

row2.Cells[2].Value = "Female";

// Clear just the bottom border of the first header row

pdfGrid.Headers[0].Cells[0].Style.Borders.Bottom = new PdfPen(Color.Black,0);

// Clear only the top borders of second header cells

foreach (PdfGridCell cell in pdfGrid.Headers[1].Cells)

{

    cell.Style.Borders.Top = new PdfPen(Color.Black,0);

}

// Optional: customize other cell borders

row2.Cells[0].Style.Borders.Bottom.Width = 3;

row2.Cells[2].Style.Borders.Bottom.DashStyle = PdfDashStyle.Dot;

row1.Cells[0].Style.Borders.Bottom.Color = Color.Transparent;

row2.Cells[2].Style.Borders.Top.Width = 3;

row2.Cells[2].Style.Borders.Top.Color = Color.Red;

// Draw the grid on the page

pdfGrid.Draw(page, new PointF(0, 0))


Regards,

Irfana J. 



HA Hartmut June 24, 2025 01:29 PM UTC

Thank you very much.


Loader.
Up arrow icon