Replace line feed in RTF

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am replacing tags with db info. My problem is I some of the addresses do
NOT have an address1. end up with a blank line. I want to get rid of that line

I am using the following code to replace

tempbbb.Rtf = tempbbb.Rtf.Replace("<address1>", newArray.ToString());


<firstName> <lastName>
<address>
<addresss1>
<city>, <state> <zip>

Dear Dave,

This is the letter.

Notice I have line breaks in the text.

If there is no address1 I end up with...

Dave Smith
117 street

mytown, OH 11111



I want

Dave Smith
117 street
mytown, OH 11111

Dear Dave,

This is the letter.

Notice I have line breaks in the text.
 
Maybe something like this will work:

if(newArray.ToString().Length == 0)
tempbbb.Rtf = tempbbb.Rtf.Replace(Environment.NewLine +
"<address1>", "");
else
tempbbb.Rtf = tempbbb.Rtf.Replace("<address1>",
newArray.ToString());

You may have to examine exactly what your file is using for newline,
and change the Environment.NewLine to be what you find.

=====================
Clay Burch
Syncfusion, Inc.
 
Back
Top