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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Text wrapping issue in PdfCell

Thread ID:

Created:

Updated:

Platform:

Replies:

128234 Jan 10,2017 08:52 AM UTC Jan 11,2017 12:04 PM UTC Xamarin.Forms 2
loading
Tags: PDF
Mohit Singh
Asked On January 10, 2017 08:52 AM UTC

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);



Mohit Singh
Replied On 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;
  



Gayathri Ramalingam [Syncfusion]
Replied On 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 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;