5 Answers, 1 is accepted
The file-previwing functionality provided in FileExplorer is entirely handled by the browser itself and cannot be controlled by us. If the browser is able to open a specific file type (e.g. the machine has third party plug-in for reading such files like in a PDF scenario), FileExplorer also will be able to preview this file. By default the browsers does not support previewing of Microsoft Office file formats.
Regards,
Vessy
Telerik
Hi Vessy,
I was trying to implement Group Docs Viewer to solve the problem. But when I double click on the file in rad file explorer no information is showing up.
fileviewer.aspx where groupdocs is being used
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FileViewer.aspx.cs" Inherits="jquerytreeview.FileViewer" %>
<%@ Import Namespace="Groupdocs.Web.UI" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<%=Viewer.CreateScriptLoadBlock().LoadJquery(true).LoadJqueryUi(true).UseHttpHandlers()%>
<style>
/*body, html {
height: 100%;
}*/
body {
overflow: hidden;
}
</style>
</head>
<body>
<div id="viewer" style="width: 100%; height: 100%;text-align: center;"></div>
<%= Viewer.ClientCode()
.TargetElementSelector("#viewer")
.Stream(System.IO.File.OpenRead(this.Filepath),this.Filename, this.FileType,this.DisplayFileName,true)
.UseHtmlBasedEngine(this.Mode)
.UseInnerThumbnails(false).OpenThumbnails(false)
.SupportPageRotation()
.ShowFolderBrowser(false)
.ShowViewerStyleControl(false)
.ZoomToFitHeight(true)
.Quality(100)
.BackgroundColor("#c60000")
.SupportPageRotation(false)
%>
<script type="text/javascript">
function Check() {
var new_width = $(window).width();
$("#viewer").groupdocsViewer("setWidth", new_width);
var threshold = 860;
if (new_width < threshold) {
var new_zoom = new_width * 100 / threshold;
$("#viewer").groupdocsViewer("setZoom", new_zoom);
} else {
$("#viewer").groupdocsViewer("setZoom", 100);
}
}
$(document).ready(function () {
$(document).bind('touchstart,touchmove', function (e) {
e.preventDefault();
});
var containerElement = $("#viewer");
containerElement.groupdocsViewer("on", "documentLoadCompleted.groupdocs",
function (e) {
Check();
});
});
$(window).resize(function () {
Check();
});
</script>
</body>
</html>
Fileviewer.aspx.cs
public partial class FileViewer : System.Web.UI.Page
{
public String Filepath;
public String Filename;
public String DisplayFileName;
public String FileType;
public Boolean Mode;
protected void Page_Load(object sender, EventArgs e)
{
string filePath = Request.QueryString["filePath"];
this.DisplayFileName = "FileName";
this.Filename = "FileName";
this.Mode = true;
this.Filepath = filePath;
this.FileType = "pdf";
}
Hi Vessy,
I was able to integrate group docs viewer with telerik rad file explore. But I am not able to open the images i.e .jpg file in document viewer. they are being opened in the telerik rad window. Any suggestions please.
function OnClientFileOpen(oExplorer, args) {
var item = args.get_item();
var fileExtension = item.get_extension();
var fileDownloadMode = true;
if ((fileDownloadMode == true) && (fileExtension == "docx" || fileExtension == ".jpg" || fileExtension == "pdf" || fileExtension == "xlsx" || fileExtension == "txt")) {
args.set_cancel(true);
var requestImage = "Handler.ashx?path=" + item.get_url();
document.location = requestImage;
}
}
code inside Handler.ashx
public void ProcessRequest(HttpContext context)
{
Context = context;
string filePath = context.Request.QueryString["path"];
filePath = context.Server.MapPath(filePath);
if (filePath == null)
{
return;
}
System.IO.StreamReader streamReader = new System.IO.StreamReader(filePath);
System.IO.BinaryReader br = new System.IO.BinaryReader(streamReader.BaseStream);
byte[] bytes = new byte[streamReader.BaseStream.Length];
br.Read(bytes, 0, (int)streamReader.BaseStream.Length);
if (bytes == null)
{
return;
}
streamReader.Close();
br.Close();
string extension = System.IO.Path.GetExtension(filePath);
string fileName = System.IO.Path.GetFileName(filePath);
if (extension == ".jpg")
{ // Handle *.jpg and
//WriteFile(bytes, fileName, "image/jpeg jpeg jpg jpe", context.Response);
context.Response.Redirect(String.Format("FileViewer.aspx?filePath={0}", filePath));
}
else if (extension == ".gif")
{// Handle *.gif
WriteFile(bytes, fileName, "image/gif gif", context.Response);
}
else if (extension == ".docx")
{
// Handle *.pdf
//WriteFile(bytes, fileName, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", context.Response);
context.Response.Redirect(String.Format("FileViewer.aspx?filePath={0}", filePath));
}
else if (extension == ".pdf")
{
context.Response.Redirect(String.Format("FileViewer.aspx?filePath={0}", filePath));
}
else if (extension == ".xlsx")
{
context.Response.Redirect(String.Format("FileViewer.aspx?filePath={0}", filePath));
}
else if (extension == ".txt")
{
context.Response.Redirect(String.Format("FileViewer.aspx?filePath={0}", filePath));
}
}
Configuring third party tools is out of the scopes of our support services, and I am afraid that I cannot provide you any assistance on this matter. My advise is to contact the support of the found by you document viewer and address your further questions about this tool to them, as they are much more acquainted with their product.
Regards,
Vessy
Telerik