2014-03-06 84 views
1
byte[] bytes = null; 
string strDeviceInfo = ""; 
string strMimeType = ""; 
string strEncoding = ""; 
string strExtension = ""; 
string[] strStreams = null; 
Warning[] warnings = null; 

try 
{ 
    ReportDataSource rds = new ReportDataSource("f_MANPOWERREQUISITION"); 
    ReportViewer rptViewer1 = new ReportViewer(); 
    rptViewer1.ProcessingMode = ProcessingMode.Local; 
    rptViewer1.LocalReport.ReportPath = Server.MapPath("Report.rdlc"); 
    bytes = rptViewer1.LocalReport.Render(strFormat, strDeviceInfo, out strMimeType, out strEncoding, out strExtension, out strStreams, out warnings); 
    Response.Buffer = true; 
    Response.Clear(); 
    Response.ContentType = strMimeType; 
    Response.AddHeader("content-disposition", "attachment; filename=" + strNomFichier + "." + strFormat); 
    Response.BinaryWrite(bytes); // create the file 
    Response.Flush(); 
}// send it to the client to download 
catch (Exception ex) 
{ 
} 

此代碼用於下載PDF文件..但我想打印該文件,以便輸出文件打開到瀏覽器的打印預覽。 因此,任何人都有助於在瀏覽器中打印PDF文件....謝謝....在Asp.net中使用響應打印rdlc報告

回答

0

感謝您發佈此代碼。我只是複製並粘貼到我的應用程序,以成功下載PDF到瀏覽器。你的問題很容易解決。更改附件;內聯;在Response.AddHeader行。

+0

雅爲它工作。 – user3001050