具有WPF RichTextBox中图像的RTF字符串将不会显示在WinForms RichTextBox中

时间:2019-02-27 21:25:56

标签: c# wpf winforms richtextbox rtf

下面的RTF字符串包含一个图像,该图像是从WPF RichTextBox创建的。当我将下面的RTF字符串设置为WinForms RichTextBox.Rtf属性时,不会显示图像。如何使图像显示在WinForms RichTextBox中?

以下是从WPF RichTextBox创建RTF字符串的代码:

  private static string ExportRtf(RichTextBox richTextBox)
  {
     var document = richTextBox.Document;
     var r = new TextRange(document.ContentStart, document.ContentEnd);
     using (var stream = new MemoryStream())
     {
        r.Save(stream, DataFormats.Rtf);
        return encoding.GetString(stream.ToArray());
     }
  }

这是WPF RichTextBox显示:

enter image description here

这是WinForms RichTextBox显示:

enter image description here

这是RTF字符串:

{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Calibri;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs21\f2\cf0 \cf0\ql{\f2 {\ltrch help}{\ltrch {\*\shppict{\pict\picwgoal435\pichgoal300\pngblip
424d460900000000000036000000280000001d00000014000000010020000000000000000000c40e0000c40e00000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff358f3afff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8ff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe4a421ffe4a421ffe4a421ffe4a421ffe4a421ffffffffffffffffff358f3afff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8ff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe4a421ffe4a421fff8f8f8ffe4a421ffe4a421ffffffffffffffffff358f3afff8f8f8fff8f8f8ff9e9e9fff444444ff444444ffbfbfc0fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8ff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe4a421ffe4a421fff8f8f8ffe4a421ffe4a421ffffffffffffffffff358f3afff8f8f8ff9e9e9fff444444ffedededfff8f8f8ffe1e1e2fff8f8f8ff444444fff8f8f8ff444444fff8f8f8fff8f8f8ff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe4a421ffe4a421ffe4a421ffe4a421ffe4a421ffffffffffffffffff358f3afff8f8f8ff444444ffcbcbccfff8f8f8fff8f8f8fff8f8f8ff444444ff444444ff444444ff444444ff444444fff8f8f8ff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff358f3afff8f8f8ff444444ffcbcbccfff8f8f8fff8f8f8fff8f8f8fff8f8f8ff444444fff8f8f8ff444444fff8f8f8fff8f8f8ff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6b145ffeed49efff9f7f2ffefd6a4ffe5ad39fffdfefdffffffffff358f3afff8f8f8ffb4b4b5ff444444ffedededfff8f8f8ffe1e1e2ff444444ff444444ff444444ff444444ff444444fff8f8f8ff358f3afffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5ead5ffe7b44cffe3a525ffe6b248fff3e7cdffffffffffffffffff358f3afff8f8f8fff8f8f8ffb4b4b5ff444444ff444444ffb4b4b5fff8f8f8ff444444fff8f8f8ff444444fff8f8f8fff8f8f8ff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff358f3afff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8ff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff358f3afff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8fff8f8f8ff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3aff358f3affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff}}}\li0\ri0\sa0\sb0\fi0\ql\par}
}
}

0 个答案:

没有答案