Read MS Word (.rtf) content from the server and paste into RichTextEditor

Hello!

I want to grab MS Word (usually in .rtf format) from the server side by calling custom API method that returns it in a format of: content="base64 string", contentType = "application/octet-stream", and then insert into RTE component. I expect it to work like as I get open .rtf file through MS Word and then copy\paste it content directly into RTE.

Basically, i have a table that lists existing files and once I click a Document Name link, the logic will get a file content fron the server and insert it into RTE.

Currently I am using "value" property and not sure how to set the content dynamically. My guess is about using a blob, but i am not certain in an approach.

I am able to convert file content into a Blob, but direct setting it as value to RTE does not work:

12-11-2021 10-25-30 AM.png

When I am receiving rtf file content type as "application/octet-stream" with byteArray content, I see the following text in RTE:

15-11-2021 10-52-00 AM.png

Thanks in advance!


5 Replies 1 reply marked as answer

VJ Vinitha Jeyakumar Syncfusion Team November 15, 2021 12:53 PM UTC

Hi Andrey, 
 
 
Currently, we are validating your reported query. We will update you the further details in two business days on or before 17th November 2021. 
 
Regards, 
Vinitha 



VJ Vinitha Jeyakumar Syncfusion Team November 15, 2021 12:53 PM UTC

Hi Andrey, 
 
 
Currently, we are validating your reported query. We will update you the further details in two business days on or before 17th November 2021. 
 
Regards, 
Vinitha 



VJ Vinitha Jeyakumar Syncfusion Team November 19, 2021 12:51 PM UTC

Hi Andrey, 
 
 
We have validated your query “Read MS Word (.rtf) content from the server and paste into RichTextEditor 
 
We want to let you know that Rich Text Editor accepts only HTML strings as value. So, you can update the .rtf content to Rich Text Editor by converting it from .rtf to HTML content. To update the converted HTML content to the Rich Text Editor you can use the ExecuteCommand method. Please check the below sample for reference, 
 
Code snippet: 
export class Default extends SampleBase { 
  val = '<p>Test</p>'; 
  buttonClick() { 
    this.rteObj.executeCommand('insertHTML', this.val); 
  } 
  render() { 
    return ( 
      <div className="control-pane"> 
        <div className="control-section" id="rte"> 
          <div className="rte-control-section"> 
            <button 
              className="e-control e-btn dlgbtn" 
              ref={this.buttonRef} 
              onClick={this.buttonClick.bind(this)} 
              id="dialogBtn" 
            > 
              {' '} 
              Insert HTML 
            </button> 
            <RichTextEditorComponent 
              id="defaultRTE" 
              ref={(richtexteditor) => { 
                this.rteObj = richtexteditor; 
              }} 
            > 
              <Inject 
                services={[HtmlEditor, Toolbar, Image, Link, QuickToolbar]} 
              /> 
            </RichTextEditorComponent> 
          </div> 
        </div> 
      </div> 
    ); 
  } 
} 
 
 
 
Please check the sample and code snippet and let us know if it satisfies your requirement. 
 
Regards, 
Vinitha 
 


Marked as answer

AB Andrey Burda replied to Vinitha Jeyakumar November 24, 2021 11:38 AM UTC

Thanks for the clarification.

That what i was thinking about.



IS Indrajith Srinivasan Syncfusion Team November 25, 2021 04:50 AM UTC

Hi Andrey,

Welcome,

Please get back to us if you need any further assistance.

Regards,
Indrajith

Loader.
Up arrow icon