I have an issue with my code but maybe it’s just that I didn’t quite understand the FixedRowHeight property.
I wanted to decide how many lines my text should take in my Table. I tried with using FixedRowHeight property but the text just keeps going after the size I give it.
Here’s my code :
var doc = new Pdf();
var section = new Section();
//create table and lines
var t1 = new Table { ColumnWidths = “200” };
var r1 = new Row(t1) { BackgroundColor = new Color(0, 0, 255) };
var c1 = r1.Cells.Add();
c1.Paragraphs.Add(
new Text(“aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”)
{TextInfo = new TextInfo{FontSize = 11}});
//Should giev the row the right height
r1.FixedRowHeight = 11;
t1.Rows.Add(r1);
//But the second line is there and the text keeps going
var r2 = new Row(t1) { BackgroundColor = new Color(0, 255, 0) }; ;
I have tested the scenario and I am able to notice the same problem. For the sake of correction, I have logged this problem as PDFNEWNET-31846 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction.
In fact I still have the problem beacause my text in my cell has several lines.
I found a workaround by replacing all the \n and \r in my text but it seems a little strange to me that the line of the text are not considered by the IsFixedRowHeightContentClip option.
Here’s my new sample code :
var doc = new Pdf();
var section = new Section();
//create table and lines
var t1 = new Table { ColumnWidths = “200”, IsFixedRowHeightContentClip = true};
var r1 = new Row(t1) { BackgroundColor = new Color(0, 0, 255) };
var c1 = r1.Cells.Add();
c1.Paragraphs.Add(
new Text(“FirstLineText\nSecondLineText\nThirdLineText\n”)
{TextInfo = new TextInfo{FontSize = 11}});
r1.FixedRowHeight = 11;
//Should give the row the right height
t1.Rows.Add(r1);
//But the second line is there and the text keeps going
var r2 = new Row(t1) { BackgroundColor = new Color(0, 255, 0) }; ;
r2.Cells.Add(“I’m the second line!!!”) ;
t1.Rows.Add(r2);
section.Paragraphs.Add(t1);
doc.Sections.Add(section);
Thanks in advance for any explanation or fix
EDIT : I don’t understand, in one of my texts I had tabulations and I had to replace all the \t also so that it works.
Thanks for your feedback and Sorry for the late reply.
I have tested the scenario and I am able to notice the same problem. For the sake of correction, I have updated this problem as PDFNEWNET-31846 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction.