We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Text wrapping issue in PdfCell

Text wrapping doesn't work. What am I doing wrong?


PdfGrid grid = new PdfGrid();
                grid.Columns.Add(3);
                grid.Headers.Add(1);
                grid.Columns[1].Width = 80;
                grid.Columns[2].Width = 180;

                PdfGridRow pdfGridHeader = grid.Headers[0];
                pdfGridHeader.Cells[0].Value = "Description";
                pdfGridHeader.Cells[1].Value = "Responsibility";
                pdfGridHeader.Cells[2].Value = "Complete By";
                pdfGridHeader.ApplyStyle(GridHeaderStyle);

                foreach (var issue in previousIssues)
                {
                    PdfGridRow pdfGridRow = grid.Rows.Add();
PdfGridCellStyle cellStyle = new PdfGridCellStyle();
                cellStyle.Font = BodyFont;
                cellStyle.TextBrush = PdfBrushes.Black;
                cellStyle.CellPadding = new PdfPaddings(5f, 5f, 5f, 5f);
                cellStyle.StringFormat = new PdfStringFormat();
                cellStyle.Borders.All = PdfPens.Gray;
                // Wraps word
                cellStyle.StringFormat.WordWrap = PdfWordWrapType.Word;
                return cellStyle;
 
 
                    pdfGridRow.ApplyStyle(GridCellStyle);

                    pdfGridRow.Cells[0].Value = issue.Description;
                    pdfGridRow.Cells[1].Value = issue.Responsibility.ToString();
                    pdfGridRow.Cells[2].Value = issue.CompleteBy.ToString("D");
                }

                PdfGridLayoutFormat layoutFormat = new PdfGridLayoutFormat();
                layoutFormat.Layout = PdfLayoutType.Paginate;
                PdfGridLayoutResult gridResult = grid.Draw(page, new RectangleF(new PointF(0, result.Bounds.Bottom + 10), new SizeF(g.ClientSize.Width, g.ClientSize.Height - 100)), layoutFormat);



4 Replies

MS Mohit Singh January 10, 2017 08:54 AM UTC

Actual code (Copy past issue). Issue is with cellstyle? But I don't get it.


var g = page.Graphics;

            /* Header */
            var element = new PdfTextElement("UNRESOLVED ISSUED FROM PREVIOUS VISITS", SubHeadingFont);
            element.Brush = new PdfSolidBrush(new PdfColor(34, 83, 142));
            result = element.Draw(page, new PointF(10, result.Bounds.Bottom + 25));

            g.DrawLine(new PdfPen(new PdfColor(34, 83, 142), 0.70f), new PointF(0, result.Bounds.Bottom + 3), new PointF(g.ClientSize.Width, result.Bounds.Bottom + 3));

            /* Output */

            if (previousIssues.Count == 0)
            {
                element = new PdfTextElement("No issues.", BodyFont,BlackSolidBrush);
                element.Draw(page, new PointF(10, result.Bounds.Bottom + 10));
            }
            else 
            {
                PdfGrid grid = new PdfGrid();
                grid.Columns.Add(3);
                grid.Headers.Add(1);
                grid.Columns[1].Width = 80;
                grid.Columns[2].Width = 180;

                PdfGridRow pdfGridHeader = grid.Headers[0];
                pdfGridHeader.Cells[0].Value = "Description";
                pdfGridHeader.Cells[1].Value = "Responsibility";
                pdfGridHeader.Cells[2].Value = "Complete By";
                pdfGridHeader.ApplyStyle(GridHeaderStyle);

                foreach (var issue in previousIssues)
                {
                    PdfGridRow pdfGridRow = grid.Rows.Add();

                PdfGridCellStyle cellStyle = new PdfGridCellStyle();
                cellStyle.Font = BodyFont;
                cellStyle.TextBrush = PdfBrushes.Black;
                cellStyle.CellPadding = new PdfPaddings(5f, 5f, 5f, 5f);
                cellStyle.StringFormat = new PdfStringFormat();
                cellStyle.Borders.All = PdfPens.Gray;
                // Wraps word
                cellStyle.StringFormat.WordWrap = PdfWordWrapType.Word;
                    pdfGridRow.ApplyStyle(cellStyle);

                    pdfGridRow.Cells[0].Value = issue.Description;
                    pdfGridRow.Cells[1].Value = issue.Responsibility.ToString();
                    pdfGridRow.Cells[2].Value = issue.CompleteBy.ToString("D");
                }

                PdfGridLayoutFormat layoutFormat = new PdfGridLayoutFormat();
                layoutFormat.Layout = PdfLayoutType.Paginate;
                PdfGridLayoutResult gridResult = grid.Draw(page, new RectangleF(new PointF(0, result.Bounds.Bottom + 10), new SizeF(g.ClientSize.Width, g.ClientSize.Height - 100)), layoutFormat);

                return gridResult;
  




GR Gayathri Ramalingam Syncfusion Team January 11, 2017 12:04 PM UTC

Hi Mohit, 
 
A support incident to track the status of reported issue has been created under your account. Please log on to our support website to check for further updates.    
   
 
 
With Regards, 
Gayathri R 
 



LG Leandro Garcia Pedroza September 27, 2022 02:18 PM UTC

I'm having the same problem with my code. What is the solution for you?


Thanks


Leandro



IJ Irfana Jaffer Sadhik Syncfusion Team September 30, 2022 10:54 AM UTC

Hi Leandro,


We were able to reproduce the reported behavior with the provided details on our end. currently, we are validating this and will provide further details on September 30th, 2022.


we have created a ticket. Please follow up and get details for this reported issue in the respective ticket.


Please let us know if you need any further assistance in this.


Regards,

Irfana J.


Loader.
Up arrow icon