我在下面的代码处理本地(using source code)
完全正常。但是当我在IIS7
上发布PDF
时,Dim strPath = Server.MapPath("~\Reports\GeneratedReport.pdf")
my_rpt.ExportToDisk(ExportFormatType.PortableDocFormat, strPath)
Dim file = New System.IO.FileInfo(strPath)
Dim Process = New Process()
If file.Exists Then
Process.StartInfo.UseShellExecute = True
Process.StartInfo.FileName = strPath
Process.Start()
Else
'No Report found
End If
不再显示..是否存在IIS问题或? 。 。我花了很多天才解决这个问题。
<select onchange="location = this.value;">
<option value="/finished">Finished</option>
<option value="/break">Break</option>
<option value="/issue">Issues</option>
<option value="/downtime">Downtime</option>
</select>
如下图所示,您看到AdobeReader正在运行,但它没有显示在我的屏幕上。
答案 0 :(得分:1)
当你说&#34;没有显示&#34;我假设您希望在客户端而不是服务器上打开PDF。通常您会将文件发送到浏览器。 Process.Start()
将启动进程服务器端,因此即使允许AppPool启动进程,它也只会在服务器上打开pdf。
以下是将文件从服务器发送到客户端的方法。
string strPath = Server.MapPath("~/reports/GeneratedReport.pdf");
//read the file from disk and convert to a byte array
byte[] bin = File.ReadAllBytes(strPath);
//clear the buffer stream
Response.ClearHeaders();
Response.Clear();
Response.Buffer = true;
//set the correct contenttype
Response.ContentType = "application/pdf";
//set the correct length of the data being send
Response.AddHeader("content-length", bin.Length.ToString());
//set the filename for the file
Response.AddHeader("content-disposition", "attachment; filename=\"GeneratedReport.pdf\"");
//send the byte array to the browser
Response.OutputStream.Write(bin, 0, bin.Length);
//cleanup
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
VB
Dim strPath As String = Server.MapPath("~/reports/GeneratedReport.pdf")
'read the file from disk and convert to a byte array
Dim bin() As Byte = File.ReadAllBytes(strPath)
'clear the buffer stream
Response.ClearHeaders
Response.Clear
Response.Buffer = true
'set the correct contenttype
Response.ContentType = "application/pdf"
'set the correct length of the data being send
Response.AddHeader("content-length", bin.Length.ToString)
'set the filename for the file
Response.AddHeader("content-disposition", "attachment; filename=""GeneratedReport.pdf"""")", send the byte array to the browser, Response.OutputStream.Write(bin, 0, bin.Length))
'cleanup
Response.Flush
HttpContext.Current.ApplicationInstance.CompleteRequest
答案 1 :(得分:0)
如果您想在自己的网站上显示PDF,可以使用以下几个javascript工具来帮助您完成此操作:
https://github.com/mozilla/pdf.js/
就个人而言,我没有使用这些工具中的任何一种,但它们似乎足以满足您的目标。