Open docx file

Hello sir,

there is a way to open .docx files with your new  SfRichTextEditor or there is a way to convert the docx content, keeping the formatting, in a way that I can open it on a  SfRichTextEditor?

Any other way It will be appreciated, the main task is to bring some content ready coming from a docx file and open it on your new  SfRichTextEditor in order to let the user modify and save even in a new format, I don't need to save on the same format as a .docx..

I can even convert my docx file in a different format if there is a tool and if the new SfRichTextEditor has a format of files to use with it, so I can open directly the file with the  SfRichTextEditor.

Thanks

Massimiliano


6 Replies

VR Vallarasu Ravichandran Syncfusion Team March 11, 2026 11:14 AM UTC

Hi Massimiliano,

 

Thank you for contacting us.

We would like to inform you that the .NET MAUI SfRichTextEditor (RTE) control is currently in the preview stage, and we are actively working to enhance its stability, capabilities, and overall performance.

 

At present, the Rich Text Editor does not provide built‑in support for directly importing Microsoft Word (.docx) files. However, you can still achieve your requirement by converting the DOCX file into HTML and then loading that HTML content into the RTE using the HTMLText property.

 

To do this, you may use any document‑processing library, including the Syncfusion DocIO library, which supports DOCX → HTML conversion while preserving formatting elements. Once converted, the generated HTML can be assigned directly to the RTE for editing.

 

We have validated this workflow successfully using Syncfusion DocIO, and below we’ve shared a code snippet and a demo for your reference.

 

  private async void OnConvertClicked(object? sender, EventArgs e)

      {

          if (string.IsNullOrEmpty(pickedFilePath))

          {

              return;

          }

          try

          {

              using (var doc = new Syncfusion.DocIO.DLS.WordDocument(pickedFilePath, Syncfusion.DocIO.FormatType.Docx))

              using (var htmlStream = new MemoryStream())

              {

                  doc.Save(htmlStream, Syncfusion.DocIO.FormatType.Html);

                  htmlStream.Position = 0;

                  using (var reader = new StreamReader(htmlStream))

                  {

                      var htmlText = await reader.ReadToEndAsync();

                      // Set html content to RTE

                      rte.HtmlText = htmlText;

                  }

              }

          }

          catch (Exception ex)

          {

          }

      }

  }

 

If you have any additional questions, please feel free to reach out. We’re always happy to help!

 

Regards,

Vallarasu R


Attachment: RTEOutput_da9fd532.zip


RM Rivetti Massimiliano March 11, 2026 05:33 PM UTC

Thanks!

It works exactly as you mentioned!



PR Preethi Rajakandham Syncfusion Team March 12, 2026 05:23 AM UTC

Hi Rivetti Massimiliano,

You are welcome.

We are glad to know that the reported problem has been resolved. Please let us know if you require any further assistance with this. We will be happy to assist you.


Regards,
Preethi R



GR George Robinson March 19, 2026 08:06 AM UTC

SfRichTextEditor does not support opening .docx directly, so converting the document to HTML or RTF first is usually the easiest approach while keeping most of the formatting. You might try using a library or tool that converts docx to HTML and then load that content into the editor.

https://www.syncfusion.com/forums/198180/open-docx-file?reply=zwfepi geometry game 2



RM Rivetti Massimiliano April 9, 2026 02:50 PM UTC

Hello sir,


after some trial I've few unexpected behaviour, here it is:


  1. When I convert a docx that has some margin in the document, the margin is not shown in the SfRichTextEditor on the view.
  2. If I modify the text on the SfRichTextEditor and then I try to save it on the converted file with this command: 
  3. File.WriteAllText(globalState.FilePathAttoHtml, richTextEditor.Text, Encoding.UTF8); or withsame behaviour with this command: 
    File.WriteAllText(globalState.FilePathAttoHtml, richTextEditor.Text);

    When I open the next time the document, it present on the top, this new text:  body{ font-family:'Times New Roman'; font-size:1em; } ul, ol{ margin-top: 0; margin-bottom: 0; } .Normal{text-align:left;page-break-inside:auto;page-break-after:auto;page-break-before:avoid;line-height:normal;margin-top:0pt;margin-bottom:0pt;font-family:'Times New Roman';font-size:12pt;text-transform:none;font-weight:normal;font-style:normal;font-variant:normal;text-decoration: none;} .Default_Paragraph_Font{font-family:'Times New Roman';font-size:10pt;text-transform:none;font-weight:normal;font-style:normal;font-variant:normal;text-decoration: none;} .Hyperlink{font-family:'Times New Roman';font-size:10pt;text-transform:none;font-weight:normal;font-style:normal;font-variant:normal;text-decoration: underline;} .Table_Normal{} .No_List{} .Di_default{text-align:left;page-break-inside:auto;page-break-after:auto;page-break-before:avoid;line-height:119.99999%;margin-top:8pt;margin-bottom:0pt;margin-left:0pt;text-indent:0pt;margin-right:0pt;color:#000000;font-family:'Helvetica Neue';font-size:12pt;text-transform:none;font-weight:normal;font-style:normal;font-variant:normal;text-decoration: none;}  

    and the text lost the alignement.


    Thanks

    Massimiliano




BP Baranibharathi Pandian Syncfusion Team April 10, 2026 09:50 AM UTC

Hi Massimiliano,

 

When a DOCX file is converted to HTML and loaded into the SfRichTextEditor, Word document margins are not displayed. This is expected behavior because DOCX margins are pagelevel properties, while the editor renders content using an HTML flow layout. Margins will only appear if they are explicitly applied using custom CSS in the HTML.

 

The issue where CSS appears at the top of the document and text alignment is lost occurs when the editor content is saved as plain text instead of HTML. Plaintext saving removes formatting information, causing internal styles to appear as visible text when the document is reopened. To avoid this, the content should be saved using the editor’s HTML value.

 

Code snippet:

 

var htmlContent = richTextEditor.HtmlText;

await File.WriteAllTextAsync(savedHtmlFilePath, htmlContent, Encoding.UTF8);

 

A demo illustrating this behavior will be shared. Please let us know if you have any further questions.

 

Regards,

Baranibharathi P.


Attachment: RTEOutput_d4ce6e7d.zip

Loader.
Up arrow icon