3 Answers, 1 is accepted
0
hwsoderlund
Top achievements
Rank 1
answered on 05 Oct 2011, 07:48 PM
This is unfortunately not possible because of a limitation in the Silverlight plugin itself. Silverlight can only access plain text in the clipboard. As far as I know this will not change in Silverlight 5. Let us hope that Silverlight 6, if that ever happens, will extend the clipboard support to rich text and images.
0
Samuel
Top achievements
Rank 1
answered on 05 Oct 2011, 07:56 PM
I think in one of your previous posts you have answered saying:
If you use the built-in "Insert Image" function in the RichTextBox, the images will be inserted inline in the xaml as base64-encoded strings.
Can I please have a step by step explanation for this? If you have an example code that will be great.
Appreciate your help!
If you use the built-in "Insert Image" function in the RichTextBox, the images will be inserted inline in the xaml as base64-encoded strings.
Can I please have a step by step explanation for this? If you have an example code that will be great.
Appreciate your help!
0
Hello Samuel,
Therefore, as long as you have the image stream and know its format, you can insert it in the document. Greetings,
Iva
the Telerik team
Henrik's right about the Silverlight clipboard and the options it provides. That is why it would not be possible to obtain anything more than plain text from the clipboard and paste it in the rich text box.
When it comes to the InsertImage method of RadRichTextBox, it takes a stream and an extension, which specifies what is the format of the image and inserts the image at the current caret position. For example, this method is used when the InsertPictureCommand is triggered. The same method is used in our online demo when you drop an image file on the document:
private
void
editor_Drop(
object
sender, DragEventArgs e)
{
FileInfo[] droppedFiles = e.Data.GetData(DataFormats.FileDrop)
as
FileInfo[];
foreach
(FileInfo droppedFile
in
droppedFiles)
{
if
(
this
.IsSupportedImageFormat(droppedFile.Extension))
{
using
(Stream imageStream = droppedFile.OpenRead())
{
this
.editor.InsertImage(imageStream, droppedFile.Extension);
}
}
}
}
private
bool
IsSupportedImageFormat(
string
p)
{
return
(p ==
".jpg"
) ||
(p ==
".jpeg"
) ||
(p ==
".png"
) ||
(p ==
".bmp"
);
}
Therefore, as long as you have the image stream and know its format, you can insert it in the document. Greetings,
Iva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>