ASP.NET 文档下载及PDF预览(电脑得安装Adobe)
2018-01-09 11:09
435 查看
protected void download_Click(object sender, EventArgs e)//文档下载
{
Database db = new Database();
string Guidstr = Request.Form.Get("checkGuid");
//Response.Write(Guidstr);
if (Guidstr.Split(',').Length > 1)
{
Response.Write("<script type='text/javascript'>alert('下载时候不能选择多个文档一起下载,请重新选择!');</script>");
}
else if (Guidstr != "" && Guidstr != null && Guidstr.Split(',').Length == 1)
{
string sql = "select FileName,FileContent,FileSize from tb_OldInput where Guidstr='" + Guidstr + "'";
DataTable dt = db.GetTable(sql);
if (dt.Rows.Count > 0)
{
Response.Clear();
String strFileName = dt.Rows[0]["FileName"].ToString();
int FileSize = int.Parse(dt.Rows[0]["FileSize"].ToString());
Response.ContentType = "APPLICATION/OCTET-STREAM";
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(strFileName));
Response.Buffer = true;
Response.BinaryWrite((Byte[])dt.Rows[0]["FileContent"]);
Response.Flush();
Response.End();
}
}
}
protected void Look_Click(object sender, EventArgs e)//PDF文档查看
{
Database db = new Database();
string Guidstr = Request.Form.Get("checkGuid");
//Response.Write(Guidstr);
if (Guidstr.Split(',').Length > 1)
{
Response.Write("<script type='text/javascript'>alert('查看时候不能选择多个文档一起查看,请重新选择!');</script>");
}
else if (Guidstr != "" && Guidstr != null && Guidstr.Split(',').Length == 1)
{
string sql = "select FileContent from tb_OldInput where Guidstr='" + Guidstr + "'";
DataTable dt = db.GetTable(sql);
if (dt.Rows.Count > 0)
{
byte[] Files = (byte[])dt.Rows[0]["FileContent"];
Response.ContentType = "application/pdf";
Response.BinaryWrite(Files);
Response.End();
}
}
}
{
Database db = new Database();
string Guidstr = Request.Form.Get("checkGuid");
//Response.Write(Guidstr);
if (Guidstr.Split(',').Length > 1)
{
Response.Write("<script type='text/javascript'>alert('下载时候不能选择多个文档一起下载,请重新选择!');</script>");
}
else if (Guidstr != "" && Guidstr != null && Guidstr.Split(',').Length == 1)
{
string sql = "select FileName,FileContent,FileSize from tb_OldInput where Guidstr='" + Guidstr + "'";
DataTable dt = db.GetTable(sql);
if (dt.Rows.Count > 0)
{
Response.Clear();
String strFileName = dt.Rows[0]["FileName"].ToString();
int FileSize = int.Parse(dt.Rows[0]["FileSize"].ToString());
Response.ContentType = "APPLICATION/OCTET-STREAM";
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(strFileName));
Response.Buffer = true;
Response.BinaryWrite((Byte[])dt.Rows[0]["FileContent"]);
Response.Flush();
Response.End();
}
}
}
protected void Look_Click(object sender, EventArgs e)//PDF文档查看
{
Database db = new Database();
string Guidstr = Request.Form.Get("checkGuid");
//Response.Write(Guidstr);
if (Guidstr.Split(',').Length > 1)
{
Response.Write("<script type='text/javascript'>alert('查看时候不能选择多个文档一起查看,请重新选择!');</script>");
}
else if (Guidstr != "" && Guidstr != null && Guidstr.Split(',').Length == 1)
{
string sql = "select FileContent from tb_OldInput where Guidstr='" + Guidstr + "'";
DataTable dt = db.GetTable(sql);
if (dt.Rows.Count > 0)
{
byte[] Files = (byte[])dt.Rows[0]["FileContent"];
Response.ContentType = "application/pdf";
Response.BinaryWrite(Files);
Response.End();
}
}
}
相关文章推荐
- 电子书下载:Adobe PDF 文档格式开发参考 PDF Reference 1.7
- java 实现在线预览pdf,word等文档
- URL rewrite 3.2 jar 和 文档 pdf 下载
- PDF编辑:Adobe Acrobat X Pro 官方原版下载+中文汉化补丁(没图)
- hadoop2.2.0_hbase0.96_zookeeper3.4.5全分布式安装文档下载
- 如何用Javascript检查Adobe PDF插件是否安装
- word文档 pdf在线预览方案
- 【资料合集】阿里巴巴开源技术汇总——内含115个软件与100+技术文档、PDF下载
- 【资料合集】阿里巴巴开源技术汇总——内含115个软件与100+技术文档、PDF下载
- 使用js下载pdf文档,点击下载不打开文档,直接下载
- 小程序开发系列(九)文档下载与预览
- java将office文档pdf文档转换成swf文件在线预览
- openOffice+jodConverter+jquery.media.js在线预览office、pdf、txt等文档
- 基于DevExpress实现对PDF、Word、Excel文档的预览及操作处理
- 官方文档 TensorFlow 下载与安装
- PDF编辑器:Adobe Acrobat XI Pro 的下载和安装
- pdf文档相关操作软件简介及其下载
- Adobe Acrobat 虚拟打印机安装方法(无法找到Adobe PDF资源文件)
- java原装代码完成pdf在线预览和pdf打印及下载
- java原装代码完成pdf在线预览和pdf打印及下载