19.4.0.52 release fixed https://www.syncfusion.com/forums/172317/pdfgridcell-columnspan-cell-width-wider-than-expected but now issue is the opposite: cells are narrower.
public void ColspanIssue2()
{
using (PdfDocument pdfDocument = new PdfDocument())
{
const float pageMargins = 15;
var section = pdfDocument.Sections.Add();
var pdfPage = section.Pages.Add();
section.PageSettings.SetMargins(pageMargins);
pdfDocument.PageSettings.SetMargins(pageMargins);
// Create root grid
PdfGrid rootGrid = new PdfGrid();
var col = rootGrid.Columns.Add();
col.Width = PdfPageSize.A4.Width - 2 * pageMargins;
var row = rootGrid.Rows.Add();
var cell = row.Cells[0];
cell.Style.Borders.All = PdfPens.Aquamarine;
// Create grid with 2 rows
const float padding = 3;
cell.Style.CellPadding = new PdfPaddings(padding, padding, padding, padding);
PdfGrid grid = new PdfGrid();
grid.Columns.Add();
grid.Columns.Add();
grid.Columns.Add();
cell.Value = grid;
void SetCell(int rowIndex, int cellIndex, string text, int colSpan = 1)
{
PdfGridCell _cell = grid.Rows[rowIndex].Cells[cellIndex];
_cell.Style.CellPadding = cell.Style.CellPadding;
_cell.Style.Borders.All = new PdfPen(Color.Black, 0.5f);
_cell.ColumnSpan = colSpan;
_cell.Value = text;
}
grid.Rows.Add();
SetCell(0, 0, "A");
SetCell(0, 1, "B");
SetCell(0, 2, "C");
grid.Rows.Add();
SetCell(1, 0, "Colspan 3: Why is this cell more narrow than above?", 3);
grid.Rows.Add();
SetCell(2, 0, "A");
SetCell(2, 1, "B");
SetCell(2, 2, "C");
grid.Rows.Add();
SetCell(3, 0, "A");
SetCell(3, 1, "Colspan 2: Why is this cell more narrow than above?", 2);
var layoutFormat = new PdfLayoutFormat { Break = PdfLayoutBreakType.FitPage, Layout = PdfLayoutType.Paginate };
rootGrid.Draw(pdfPage, new PointF(0, 0), layoutFormat);
//Save the document
string fileName = $"File{DateTime.Now.Ticks}.pdf";
pdfDocument.Save(fileName);
//Close the document
pdfDocument.Close(true);
System.Diagnostics.Process.Start(fileName);
}
}
Hi umlprog,
We were able to reproduce the reported issue with provided details and currently, we are analyzing this and we will update the further details on February 23rd 2022.
Regards,
Surya V
Hi umlprog,
Thank you for your patience.
We confirmed the issue “PdfGridCell Column Span cell width more narrow than expected” as a defect in our product. We will include the fix for this issue in our weekly NuGet release, which will be available on March 8th, 2022.
Please use the below feedback link to track the status of the reported bug.
Note: If you require 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.
Please let us know if you need any further assistance in this.
Regards,
Surya V