FlowDocumentReader - carriage return line feed characters are added to the end of text that has none

326 Views Asked by At

I'm adding text to a FlowDocumentReader within a single paragraph like this

FlowDocumentReader fdr = new FlowDocumentReader();
fdr.Document = new FlowDocument();

Paragraph p = new Paragraph();
Run r = new Run("some text");

p.Inlines.Add(r);

fdr.Document.BLocks.Add(p);

NOTE: I am actually combining multiple runs of text into one paragraph.

However, when I display the text in the FlowDocumentReader, it always shows some extra characters after the very last character of the text I inserted. When I try to drag and select the entire text, and copy, it goes beyond the last character. And when I paste the entire selection to Notepad++ it shows there is a CR LF characters at the end.

So if I start with this text

some text

I end up with

some text\r\n

Is there anyway to eliminate these from becoming part of the text in the FlowDocumentReader itself? I actually don't want them to appear in the FlowDocumentReader. I require that the text not contain any additional characters beyond those that were part of the original text I added to the Runs.

The closest issue I can find similar to this is for RichTextBox Why does RichTextBox implicitly add newline?

0

There are 0 best solutions below