简体   繁体   English

WPF RichTextBox:输出RTF与输入不同

[英]WPF RichTextBox: Output RTF is different from input

I'm loading a valid RTF (let's say just a binary image) string from a client application. 我正在从客户端应用程序加载有效的RTF(假设只是二进制图像)字符串。

This RTF is loaded in a WPF RichTextBox Control, and then, wighout modifying the content, I take it from the RichTextBox to send it back to the client application (so the RTF content has not suffered any change). 将该RTF加载到WPF RichTextBox控件中,然后,在不修改内容的情况下,我从RichTextBox中将其发送回客户端应用程序(因此RTF内容未发生任何更改)。

But now the RTF content is quite different. 但是现在RTF的内容已经大不相同了。 Now, it's still a valid RTF (if I copy it in a 'test.rtf' file, the image is properly shown). 现在,它仍然是有效的RTF(如果我将其复制到“ test.rtf”文件中,则图像会正确显示)。 But now in the client application, the image is not shown. 但是现在在客户端应用程序中,未显示该图像。

If I send again that "modified" RTF from the client app to my app, the image is shown in my app. 如果我再次将“修改后的” RTF从客户端应用程序发送到我的应用程序,则该图像将显示在我的应用程序中。 But again, sending it back to the client app, that image is not shown there. 但是同样,将其发送回客户端应用程序时,该图像未在此处显示。

So, to summarize, the image is not lost , but somehow I'm guessing that the RTF Format (or standard) is changed when the content is set in my RichTextBox control. 因此,总而言之, 图像不会丢失 ,但是以某种方式我猜测在RichTextBox控件中设置了内容时,RTF格式(或标准)已更改

Input RTF (from client): 输入RTF(来自客户端):

{\rtf1\ansi\ansicpg1252\deff0\deflang1036{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
{\*\generator Msftedit 5.41.21.2510;}
\viewkind4\uc1\pard\sa200\f0\fs20
{\pict\wmetafile8\picw17017\pich7624\picwgoal9360\pichgoal4200 
010009000003d04204000000a742040000000400000......

RTF after setting in RichTextBox: 在RichTextBox中设置后的RTF:

{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}
{\f2\fcharset0 Segoe UI;}{\f3\fcharset0 Tahoma;}}
{\colortbl\red0\green0\blue0;\red255\green255\blue255;}
\loch\hich\dbch\pard\plain\ltrpar\itap0
{\lang1033\fs20\f3\cf0 \cf0\ql{\f3 {\ltrch {\*\shppict{\pict\picwgoal9360\pichgoal4200\pngblip
89504e470d0a1a0a0000000d494844......

Any help? 有什么帮助吗? Thanks :) 谢谢 :)

WPF RichTextBox only supports limited use of processing images. WPF RichTextBox仅支持有限使用处理图像。 Relative linking, graphic metafiles, and images not in the JPG, PNG, or GIF format are some notable incompatibilities. 相对链接,图形图元文件和非JPG,PNG或GIF格式的图像有些明显的不兼容性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM