不用SCRIPT语言,在ASP.NET中如何直接打开PDF文件?已知PDF文件的物理地址和PDF表示用URL。

解决方案 »

  1.   

    http://dev.csdn.net/develop/article/62/62119.shtm
      

  2.   

    用以下的代码可以打开PDF文件,只是在当前页面直接打开了,想在一个新的页面打开PDF文件,该如何修改代码?'Set the appropriate ContentType.
    Response.ContentType = "Application/pdf"
    'Get the physical path to the file.
    Dim FilePath As String = MapPath("acrobat.pdf")
    'Write the file directly to the HTTP content output stream.
    Response.WriteFile(FilePath)
    Response.End()
      

  3.   

    你可以试试,public Open_pdf_File_ByPath(string Pdf_Path)
    {//通过文件路经Pdf_path,打开。
       //string Pdf_Path="C:\\xnbook\\1.pdf";
    System.Text.StringBuilder sbTemp = new System.Text.StringBuilder(1000);
    sbTemp.Append("<OBJECT id=\"Pdf1\" style=\"LEFT: 0px; TOP: 0px\" height=\"100%\" width=\"100%\" classid=\"clsid:CA8A9780-280D-11CF-A24D-444553540000\"VIEWASTEXT>");
    sbTemp.Append("<PARAM NAME=\"_Version\" VALUE=\"327680\"> <PARAM NAME=\"_ExtentX\" VALUE=\"2646\"> <PARAM NAME=\"_ExtentY\" VALUE=\"1323\"> <PARAM NAME=\"_StockProps\" VALUE=\"0\"> <PARAM NAME=\"SRC\" VALUE=\""+Pdf_Path+"\">");
    sbTemp.Append(" <!--url of PDF file --> 您没有安装Acrobat Reader5.0,请点此处下载:<a href='.....'>Acrobat Reader5.0</a></OBJECT>");


    Page.RegisterStartupScript("alert", sbTemp.ToString());}