pdfgrid wrong row height

Hi,
I have the following code:

static void Main(string[] args)
        {
            PdfDocument document = new PdfDocument();

            PdfPage page = document.Pages.Add();

            PdfGrid pdfDocumentoGrid = new PdfGrid();
            pdfDocumentoGrid.Columns.Add(2);

            PdfGridRow rowprova = pdfDocumentoGrid.Rows.Add();
            rowprova.Cells[0].Value ="1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
            rowprova.Cells[0].ColumnSpan = 2;
            PdfGridRow rowTestata = pdfDocumentoGrid.Rows.Add();

            rowTestata.Cells[0].Style.Borders.All = PdfPens.Transparent;
            rowTestata.Cells[1].Style.Borders.All = PdfPens.Transparent;

            PdfGridRow rowEmpty = pdfDocumentoGrid.Rows.Add();
            rowEmpty.Cells[0].Style.Borders.All = PdfPens.Transparent;
            rowEmpty.Cells[0].Value = "";
            rowEmpty.Cells[0].ColumnSpan = 2;

            PdfGridRow rowSottoTestata = pdfDocumentoGrid.Rows.Add();
            rowSottoTestata.Cells[0].Value = PdfSottoTestaGrid();
            rowSottoTestata.Cells[0].ColumnSpan = 2;
     
            pdfDocumentoGrid.Draw(page, PointF.Empty);

            MemoryStream stream = new MemoryStream();
            document.Save(stream);
            document.Close(true);
            using (var fs = new FileStream(@"d:\Prova.pdf", FileMode.Create, FileAccess.Write))
            {
                stream.WriteTo(fs);
            }
            document.Close(true);
        }

        private static object PdfSottoTestaGrid()
        {
            PdfGrid pdfgrid = new PdfGrid();
            pdfgrid.Columns.Add(4);

            PdfGridCellStyle cellTitolettoStyle = new PdfGridCellStyle();
            cellTitolettoStyle.Borders.Top = PdfPens.Black;
            cellTitolettoStyle.Borders.Left = PdfPens.Black;
            cellTitolettoStyle.Borders.Right = PdfPens.Black;
            cellTitolettoStyle.Borders.Bottom = PdfPens.Transparent;
            cellTitolettoStyle.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 6);

            PdfGridCellStyle cellDatoStyle = new PdfGridCellStyle();
            cellDatoStyle.Borders.Top = PdfPens.Transparent;
            cellDatoStyle.Borders.Left = PdfPens.Black;
            cellDatoStyle.Borders.Right = PdfPens.Black;
            cellDatoStyle.Borders.Bottom = PdfPens.Black;
            cellDatoStyle.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 10);

            PdfGridRow row0 = pdfgrid.Rows.Add();
            row0.Cells[0].Style = cellTitolettoStyle;
            row0.Cells[0].Value = "T1";
            row0.Cells[0].ColumnSpan = 3;

            row0.Cells[3].Value = "T2";
            row0.Cells[3].Style = cellTitolettoStyle;

            PdfGridRow row1 = pdfgrid.Rows.Add();
            row1.Cells[0].Style = cellDatoStyle;
            row1.Cells[0].Value = "12345678901234567890123";
            row1.Cells[0].ColumnSpan = 3;

            row1.Cells[3].Style = cellDatoStyle;

            return pdfgrid;
        }
and this works regularly.

But why if I increase the text of the first cell of the second grid, the height of the row increases even though it has not covered all the available space?
it doesn't behave like the grid above!

example: replace row1.Cells [0] .Value = "12345678901234567890123";
with
             row1.Cells [0] .Value = "123456789012345678901234";

1 Reply 1 reply marked as answer

GK Gowthamraj Kumar Syncfusion Team November 23, 2020 11:47 AM UTC

Hi Egidio,   
 
Thank you for contacting Syncfusion support.   
 
We have checked the reported issue with the provided code snippet and found that the given text width is exceeded the first column width (Even if we set ColumnSpan, it will consider the column width). Due to this only, the row height has been increased for the text “123456789012345678901234” even with ColumnSpan. You can see this difference by removing the ColumnSpan of row1, cell1. However, we can overcome this issue by setting the width to a particular column, and please refer to the below code snippet for more details,  
 
//Setting the column width  
pdfgrid.Columns[0].Width = 100;  
 
We have modified the sample and please find the download link below,   
   
Please try the above sample on your end and let us know the result. 
 
Regards, 
Gowthamraj K 


Marked as answer
Loader.
Up arrow icon