System.Windows.Forms.RichTextBox rt1 = new System.Windows.Forms.RichTextBox();
System.Windows.Forms.RichTextBox rt2 = new System.Windows.Forms.RichTextBox();
if (condition)
{
int index = rtf1.LastIndexOf('}');
rtf1 = rtf1.Insert(index, "\\page\\par\r\n"); //Adding the page break
}
string strClipBoardData = System.Windows.Forms.Clipboard.GetText(); //Store clip board data
rt2.Copy();// copy blank data to clip board
rt1.Rtf = rtf1; rt2.Rtf = rtf2; rt2.SelectAll();
rt2.Copy();
rt1.Paste();
retValue = rt1.Rtf;
rt1.Dispose();
rt2.Dispose();
System.Windows.Forms.Clipboard.SetDataObject(strClipBoardData);//Assign clip board data back to the clip board