如何在html文件中打开PDF文件流?
我是用一下代码把得到的PDF文件流写到ASP页面上 但是实际的效果是
1。弹出下载的对话框。
2。或者直接被客户端的PDF软件打开。
但是都不是要求的在HTML中打开这个PDF的效果。 private void OpenReport(ReportResultModel4WS reportResultModel4WS)
{
string reportName = reportResultModel4WS.name;
byte[] reportContent = reportResultModel4WS.content;
string[] reponseHeaders = reportResultModel4WS.responseHeaders;
string[] reponseHeadersValues = reportResultModel4WS.responseHeadersValues;
Hashtable reponseHeaderMap = new Hashtable(); for (int i = 0; i < reponseHeaders.Length; i++)
{
reponseHeaderMap.Add(reponseHeaders[i], reponseHeadersValues[i]);
}
string contentType = (string)reponseHeaderMap["Content-Type"];
string cntDisposition = (string)reponseHeaderMap["Content-Disposition"];
Response.Clear();
Response.Buffer = true;
Response.ContentType = contentType; //e.g. "application/vnd.ms-word";
if(cntDisposition != null)
{
Response.AddHeader("Content-Disposition", cntDisposition);
//e.g. "inline;filename=" + reportName + ".doc"
} Response.AddHeader("content-length", reportContent.Length.ToString());
Response.BinaryWrite(reportContent);
Response.Flush();
Response.Close();
Response.End();
}
后来改成 用javascript打开包含上面方法的ASP页面但是弹出的是一个空白网页,PDF文件流依然是被本地PDF程序打开。
function print_onclick(url)
{
var a=window.open(url, "_blank","top=200,left=200,height=600,width=800,status=yes,toolbar=1,menubar=no,location=no,scrollbars=yes");
} 请做过类似问题的朋友帮忙给我指点一下。
马上给分。谢谢。
我是用一下代码把得到的PDF文件流写到ASP页面上 但是实际的效果是
1。弹出下载的对话框。
2。或者直接被客户端的PDF软件打开。
但是都不是要求的在HTML中打开这个PDF的效果。 private void OpenReport(ReportResultModel4WS reportResultModel4WS)
{
string reportName = reportResultModel4WS.name;
byte[] reportContent = reportResultModel4WS.content;
string[] reponseHeaders = reportResultModel4WS.responseHeaders;
string[] reponseHeadersValues = reportResultModel4WS.responseHeadersValues;
Hashtable reponseHeaderMap = new Hashtable(); for (int i = 0; i < reponseHeaders.Length; i++)
{
reponseHeaderMap.Add(reponseHeaders[i], reponseHeadersValues[i]);
}
string contentType = (string)reponseHeaderMap["Content-Type"];
string cntDisposition = (string)reponseHeaderMap["Content-Disposition"];
Response.Clear();
Response.Buffer = true;
Response.ContentType = contentType; //e.g. "application/vnd.ms-word";
if(cntDisposition != null)
{
Response.AddHeader("Content-Disposition", cntDisposition);
//e.g. "inline;filename=" + reportName + ".doc"
} Response.AddHeader("content-length", reportContent.Length.ToString());
Response.BinaryWrite(reportContent);
Response.Flush();
Response.Close();
Response.End();
}
后来改成 用javascript打开包含上面方法的ASP页面但是弹出的是一个空白网页,PDF文件流依然是被本地PDF程序打开。
function print_onclick(url)
{
var a=window.open(url, "_blank","top=200,left=200,height=600,width=800,status=yes,toolbar=1,menubar=no,location=no,scrollbars=yes");
} 请做过类似问题的朋友帮忙给我指点一下。
马上给分。谢谢。
解决方案 »
- 求救,快要做完了可又出现了这个问题,怎么解决啊,帮帮忙
- ASP 代码 检查~!实在是不知哪的问题了
- 想把地址http://localhost/index.aspx?userid=good,用http://localhost/good代替,该怎么做呢?
- 如何获取其他网页上的用户名和密码框中的输入信息 C#
- 可不可以执行完脚本后,自动执行其他的过程?
- 一个这样的asp.net+sql2005数据库的网站值多少钱呢,请各位来评评哦
- 请教高手
- .net 用npoi 怎么实现将excel数据导入gridview?
- 为什么在WINDOWS XP下面就不正常了?(经理用的XP啊!!!)
- 修改记录语句 那里出错?
- 请教如何用C#实现录音功能 感激不尽!
- Asp.net能否实现服务器推送技术?
Gmail 邮件里如果包含pdf文件的话就可以用html查看。
当然你用activeX就当我没说
你可以设置一下输出流的格式。
当然需要结合PDF工具对IE的支持才能解决问题。
回复者都有分啊 呵呵。