PDFView.aspx.cs代码
protected void Page_Load(object sender, EventArgs e) { if (Request.Browser.Browser.ToLower() != "chrome") { string filePath = Server.MapPath("pdf/19-P1012728-064_ZHCN-Draft.pdf"); Response.ClearContent(); Response.ClearHeaders(); string FilePost = filePath.Substring(filePath.Length - 3).ToLower(); switch (FilePost) { case "pdf": Response.ContentType = "application/PDF"; break; case "doc": Response.ContentType = "application/msword"; break; case "xls": Response.ContentType = "application/vnd.ms-excel"; break; default: Session["ErrorInfo"] = "不支持的文件格式:" + FilePost; Response.Redirect("ErrorPage.aspx"); break; } Response.WriteFile(filePath); Response.Flush(); Response.Close(); Session.Remove("Report"); } else if (Request.Browser.Browser.ToLower() == "chrome") { string filePath = Server.MapPath("pdf/19-P1012728-064_ZHCN-Draft.pdf"); Response.ClearContent(); Response.ClearHeaders(); string FilePost = filePath.Substring(filePath.Length - 3).ToLower(); Response.Clear(); Response.ClearHeaders(); Response.Buffer = false; if (Request.Browser.Browser == "Firefox") System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + "1.pdf"); else System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("1.pdf", System.Text.Encoding.UTF8)); using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open)) { byte[] by = new byte[fs.Length]; fs.Read(by, 0, by.Length); Response.BinaryWrite(by); Response.AddHeader("Accept-Language", "zh-tw"); Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Length ", by.Length.ToString()); System.Web.HttpContext.Current.Response.Flush(); System.Web.HttpContext.Current.Response.End(); } } }
以上就介绍了PDF在线预览 ,兼容IE,chrome。使用了pdfobject.js,包括了方面的内容,希望对.NETjrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播有兴趣的朋友有所帮助。
本文网址链接:http://www.codes51.com/article/detail_96636.html
Copyright © 2015-2016 , 版权所有 码蚁之家 codes51.com 粤ICP备14062022号
声明:《PDF在线预览 ,兼容IE,chrome。使用了pdfobject.js》由码蚁之家搜集整理于网络,
如果侵害了您的合法权益,请您及时与我们,我们会在第一时间删除相关内容!联系邮箱:mxgf168#qq.com(#改为@)