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
close icon

PdfGrid Cannot word wrap correctly

Hello,

I have a table implemented using PdfGrid. The table has 2 rows and 3 columns. First rows is simple text only, but second row has nested PdfGrid with only one column and few rows (i need to assign different fonts to different rows). When I insert a row with one word in the nested grid but the word is too long to be put on one line, it doesn't wrap correctly. It just ends with the last character possible to fit there (i have set some padding to the cells of parent table).

I discovered even weirder behaviour by accident, when I follow the word with newline and some characters, it wraps correctly (but shows only the first word). Let"s say the string is "toolongtofitoneline" which can only fit the "toolongtofit" part to one line. When I change the string to "toolongtofitoneline cat" and then add it to the grid, it wraps the "toolongtofit" and shows "oneline" on second row but nothing else (not the cat) part.

I tried setting the Style.StringFormat.WordWrap to Character but nothing helps. I have also found this question https://www.syncfusion.com/forums/130965/how-to-auto-wrap-long-text-field-in-column-in-grid but it does not apply to SyncFusion PDF library.

Best regards.

4 Replies

SK Surya Kumar Syncfusion Team June 25, 2019 01:28 PM UTC

Hi Daniel, 

Greetings from Syncfusion. 

We have tried to reproduce the issue with the PdfGrid which you have described in the last update and the text inside the nested grid found to be preserved without any issues. We have attached the sample with code snippet which we have tried to reproduce the issue.  
Sample link: 

Could you please modify the code snippet like you have used and provide the code in which issue is reproduced. So that we could help you find solution. 

Regards, 
Surya Kumar 



DK Daniel Kraut July 2, 2019 01:58 PM UTC

Hi Surya,

Sorry, I may have described the issue badly. I have edited the sample code you provide to demonstrate my issue:

#1 - My original issue: 
If I edit theline 62 from:

childGridRow1.Cells[0].Value = "toolongtofitoneline cat";

To:

childGridRow1.Cells[0].Value = "TooLongToFitOnOneLineWithHelveticaFont";

in the final table there is displayed only "TooLongToFitOnOneLineWith" and nothing else. This was my original issue with SyncFusion PDF library. Meanwhile I have figured out that one way to force correct word wrapping is to explicitly set the width of that column, which gets quite complicated to do with nested grids when I want some columns to be dynamic.

#2 The weird behaviour:

I have found this when I was experimenting with how to solve my original problem. If I edit the line 68 from:

childGridRow3.Cells[0].Value = "toolongtofitoneline cat";

To:

childGridRow3.Cells[0].Value = "TooLongToFitOneLineCourierFont";

The text is "cut off" the same as in my previous example. But when I edit that line to:

childGridRow3.Cells[0].Value = "TooLongToFitOneLineCourierFont cat";

It wraps only the "TooLongToFitOneLineCourierFont" correctly, but does not draw the "cat" part at all. I find it even weirder, that:

  • "TooLongToFitOneLineCourierFont" - this is not enough to force the word wrapping
  • "TooLongToFitOneLineCourierFont cat" - this is not enough to force the word wrapping
  • "TooLongToFitOneLineCourierFontcat" - this is enough, in another words it must be the newline character plus some other character(s)


Attachment: NestedGrid1629627736edited_80b5fcd1.zip


SK Surya Kumar Syncfusion Team July 3, 2019 07:22 AM UTC

Hi Daniel, 

We are able to reproduce the behavior which you have mentioned. We are currently analyzing the same, we let you know more about this on 05-July-19. 

Regards, 
Surya Kumar 



SK Surya Kumar Syncfusion Team July 5, 2019 01:11 PM UTC

Hi Daniel, 

Thank you for the patience. 

We confirm that the issue with “Contents inside the child grid are not word wrapped properly in PdfGrid” is a bug and the fix for this issue will be included in the Volume 2 SP1 release which is will be available on month of August 2019. 

Regards, 
Surya Kumar 


Loader.
Live Chat Icon For mobile
Up arrow icon