Reputation: 5534
There's got to be a better way to do this than what I'm doing.
I'm trying to extract the raw RTF from a WPF RichTextBox. Well, really I'm trying to take a bunch of my custom classes and turn it into an RTF string, but I'm using a RichTextBox to do it because I don't particularly want to write my own RTF library.
The method I'm using (modified from something first seen here and used to extract XML here) is as follows:
RTB.Selection.Save(memstream, DataFormats.Rtf);
memstream.Seek(0, SeekOrigin.Begin);
var sr = new StreamReader(memstream);
var myText = sr.ReadToEnd();
This works, but seems ridiculously clumsy. And I'm worried about the performance implications on large amounts of text. Is there a better way? (For the purpose of this question, let's assume that I can't use the WinForms RichTextBox.)
Upvotes: 1
Views: 551
Reputation:
use this question.
string mpic = @"{\pict\pngblip\picw" +
img.Width.ToString() + @"\pich" + img.Height.ToString() +
@"\picwgoal" + width.ToString() + @"\pichgoal" + height.ToString() +
@"\bin " + str + "}"
Upvotes: 1