日期:2014-05-18  浏览次数:20477 次

如何在html文件中打开PDF文件流?
如何在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");




请做过类似问题的朋友帮忙给我指点一下。
马上给分。谢谢。




------解决方案--------------------
一般情况下应该是被本地打开的,网页里面难直接读
就好象在线阅读一样,也是要下载阅读器才能看着
------解决方案--------------------
用 IFRAME 签入一个吧

http://www.kupoa.cn
------解决方案--------------------
用html查看是什么意思? PDF转成了HTML格式 还是什么//???
------解决方案--------------------
你觉得浏览器能阅读PDF文档?太高科技了-_-
当然你用activeX就当我没说
------解决方案--------------------
这要看客户端是否安装了PDF阅读器了。
你可以设置一下输出流的格式。