We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

PreviewHandler

Thread ID:

Created:

Updated:

Platform:

Replies:

130907 Jun 9,2017 12:01 PM UTC Jun 13,2017 11:53 AM UTC ASP.NET Web Forms 1
loading
Tags: FileExplorer
Carsten Wuttke
Asked On June 9, 2017 12:01 PM UTC

Hallo,

can I somehow register (or so) a previewhandler for another filetype than pics? Lets say doc (via docio) or pdf.

Ashokkumar Balasubramanian [Syncfusion]
Replied On June 13, 2017 11:53 AM UTC

Hi Carsten, 
 
We have analyzed your requirement (Preview the word document). We can achieve your requirement by using RTE component. Initially, in “BeforeOpen” event of FileExplorer, pass the document path to the AJAX handling “Importing” method that is available in the controller part. Then the “Importing” method process the word document and return the document content to the AJAX success method, then we should pass the returned content to the “setHtml” method of RTE component. Please refer the below code block. 
 
[SCRIPT]  
  
function OnBeforeOpen(args) { 
            if (args.itemType == "File" && (/\.(docx)$/i).test(this._selectedFile)) { 
                var file = args.model.selectedFolder + args.model.selectedItems[0]; 
                $.ajax({ 
                    url: '@Url.Action("Importing", "FileExplorer")', 
                    type: "POST", 
                    dataType: "json", 
                    data: { FilePath: file }, 
                    success: function (data) { 
                        var rte = $("#rteSample").ejRTE("instance"); 
                        rte.setHtml(data); 
                        var dialogObj = $("#dialogAPI").ejDialog("instance"); 
                        dialogObj.option("title", args.model.selectedItems[0]); 
                        dialogObj.open(); 
                    } 
                }); 
 
            } 
        } 
[Controller]  
  
public object Importing(string FilePath) 
        { 
            string HtmlString = string.Empty; 
            string path = System.Web.HttpContext.Current.Server.MapPath(FilePath); 
 
            //var path = FilePath; 
 
            if (path != null) 
            { 
                using (var mStream = new MemoryStream()) 
                { 
                    new WordDocument(path).Save(mStream, FormatType.Html); 
                    mStream.Position = 0; 
                    HtmlString = new StreamReader(mStream).ReadToEnd(); 
                }; 
 
                HtmlString = ExtractBodyContent(HtmlString); 
 
                foreach (var item in DecodeKeys()) 
                { 
                    HtmlString = HtmlString.Replace(item.Key, item.Value); 
                } 
            } 
            else HttpContext.Response.Write("Select any file to upload."); 
            return Json(HtmlString); 
        } 
For your convenience, we have prepared simple sample, it can be downloaded in below location.  
  
  
To know more details about this requirement, please refer the below forum. 
  
 
Please let us know, if you have any other concerns.  
  
Regards,  
Ashokkumar B.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;