In my application, I get an array from bytes from an XML file. With it I create a stream , but when I try to load it and insert it into XRRichText
, nothing happens. However, if I write the stream into a file on the user's computer disk, it loads perfectly when loading the file and inserting the contents into the component. Even so, I need to be uploaded through the stream, not a file.
The code below works, but I can not use it because of the creation of files on the user's computer:
RichEditDocumentServer server = new RichEditDocumentServer();
using (Stream file = File.OpenWrite(@"C:\temp\intro.xml"))
{
file.Write(pDados.ByteXML, 0, pDados.ByteXML.Length);
}
server.LoadDocument(@"C:\temp\intro.xml");
...
XRRichText x = (XRRichText)xrCont;
x.Rtf = server.RtfText;
The code below does not work, but it's how you need to do it through stream , without creating files:
RichEditDocumentServer server = new RichEditDocumentServer();
MemoryStream stream = new MemoryStream();
stream.Write(pDados.ByteXML, 0, pDados.ByteXML.Length);
stream.Flush();
stream.Position = 0;
server.LoadDocument(stream, DocumentFormat.OpenXml);
...
XRRichText x = (XRRichText)xrCont;
x.Rtf = server.RtfText;