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
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.
Hi Hartmut,
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.
Thank you very much.