This is a migrated thread and some comments may be shown as answers.

HtmlFormatProvider.Export() not exporting RadDocument correctly.

3 Answers 189 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Gaurav
Top achievements
Rank 1
Gaurav asked on 17 Oct 2016, 05:23 PM

I am implementing "edit HTML" functionality by creating a RadDocument and loading a HTML file. Once I modify the RadDocument and try to export/save with below code snippet; the newly HTML has improper rendering. By improper rendering, I mean, some additional content gets added than what appears in the RadDocument.

 

//---------------------------Code snippet of Importing-------------------------------------

document = fromFormatProvider.Import(readStream); ===========> Load the *HTM provider readStream to RadDocument

//-----------------------------------------------------------------------------------------------------

 

// -----------------------------Code snippet of Exporting-------------------------------------

               IDocumentFormatProvider fromFormatProvider = new HtmlFormatProvider();
               using (FileStream writeStream = new FileStream(emailtemplateinfo.Path, FileMode.OpenOrCreate))
                {
                    document.EnsureDocumentMeasuredAndArranged();
                    fromFormatProvider.Export(document, writeStream); ======================> Export the newly modified RadDocument to HTM provider
                }

//-----------------------------------------------------------------------------------------------------

3 Answers, 1 is accepted

Sort by
0
Gaurav
Top achievements
Rank 1
answered on 17 Oct 2016, 06:41 PM

I was able to temporarily workaround this by not using writeStream, instead, convert the bytearray to string

 

 byte[] byteArray = fromFormatProvider.Export(document);
                strHTML = System.Text.Encoding.UTF8.GetString(byteArray);
                File.WriteAllText(emailtemplateinfo.Path, strHTML);

0
Tanya
Telerik team
answered on 20 Oct 2016, 01:49 PM
Hi Gaurav,

We are unaware of such a behavior in the HtmlFormatProvider of RadRichTextBox. Could you please share more information on the scenario? How are you modifying the document? It would be of a great help if you can send us a sample document so we can test the issue on our end and check what might cause it.

If you don't want to share the data in the public forums, you can open a support ticket. In the ticketing system, you can attach .zip files while in the public forums only images are allowed.

Regards,
Tanya
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
0
Gaurav
Top achievements
Rank 1
answered on 20 Oct 2016, 03:01 PM
Thanks Tanya for your response. For now, I am not interested to explore this further. But appreciate your response.
Tags
RichTextBox
Asked by
Gaurav
Top achievements
Rank 1
Answers by
Gaurav
Top achievements
Rank 1
Tanya
Telerik team
Share this question
or