How to open a selected document into Editor ?

1 Answer 38 Views
Editor
Anisha
Top achievements
Rank 1
Anisha asked on 17 Aug 2021, 09:46 AM

Hello, is it possible to open a selected document into the editor ? I'm looking to open a document into the editor when the editor loads up. I have gone through the demos and saw its possible to import a file to the editor, however I'm looking for the editor to open up a document selected in the controller.

Thank you

Anisha

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 20 Aug 2021, 07:28 AM

Hi Anisha,

 

Thank you for writing to us.

This should be possible. Here is the related code snippet:

        public ActionResult Import(HttpPostedFileBase file)
        {
            var settings = new EditorImportSettings();
            string htmlResult;
            switch (Path.GetExtension(file.FileName))
            {
                case ".docx":
                    htmlResult = EditorImport.ToDocxImportResult(file, settings);
                    break;
                case ".rtf":
                    htmlResult = EditorImport.ToRtfImportResult(file, settings);
                    break;
                default:
                    htmlResult = EditorImport.GetTextContent(file);
                    break;
            }

            return Json(new { html = htmlResult });
        }
    }
From this demo:
https://demos.telerik.com/aspnet-mvc/editor/import-export

In your case, you will access the File statically using something like File.Open().

 

Regards,
Eyup
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Editor
Asked by
Anisha
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or