Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using pdfsharp to create pdf. I have got a big text value, so that its not fit into my table column. So that I have tried split function. But the value printed on pdf is System.String[]. Here is my code:

C#
private string[] GetLines(string strValue)
{
    string[] strLines = strValue.Split('\n');
    int lineLength = strLines.Length;
    return strLines;
}

DataRow repRow = ReportDS.Rows[rowCount];
string Result = repRow["result"].ToString();
//result.length is 558
if (Result.Length > 50)
{
    Result = GetLines(Result).ToString();
}


The value get on Result is System.String[]. I need to get values.
Posted

1. How do you draw it?
2. You probably asked it to draw the entire object at once, something like pdf.Draw(Result.ToString()).
That gives you the name of the type.
Draw it line by line.
 
Share this answer
 
That is indeed correct. You are setting an array to the result since you are setting Result to GetLines(Result) which is an array.
 
Share this answer
 
Comments
RENJITH VS 26-Mar-15 5:11am    
cannot implicitly convert type string[] to string()
What are you expecting to see? GetLines is an array, it has no natural representation as a string so when you use ToString it returns the type name which is why you see "string[]". The easiest way to see it as a string is to use string.Join

Result = string.Join (", ", GetLines(Result))


the above will show each element comma separated

e1, e2, etc

Result = string.Join (" ", GetLines(Result))


will show then in a line

e1 e2 etc

Or maybe you want to show them with html breaks if that is how your PDF works

Result = string.Join ("<br />", GetLines(Result))


We don't know what you want the array to look like so it's hard to give a definitive answer.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900