views:

336

answers:

0

Hi,

I am using WPF RichTextBox to record data and save the same in database. Now when i retrieve the same back from database and try to show the detail in a DevExpress report RichTextBox value appears as a single line of text without line break or new lines or table format. This is what i am doing

Converting FlowDocument to byte[] to save in database.

var content = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);
            if (content.CanSave(DataFormats.Rtf))
            {
                using (var stream = new MemoryStream())
                {
                    content.Save(stream, DataFormats.Rtf);
                    return stream.ToArray();
                }
            }

Converting byte array to text to display in report

    FlowDocument doc = new FlowDocument();
string rtfText = null;
                        using (MemoryStream stream = new MemoryStream(byteArrayValue))
                        {
                            TextRange text = new TextRange(doc.ContentStart, doc.ContentEnd);
                            text.Load(stream, DataFormats.Text);
                            rtfText  = text.Text;

                        }