简体   繁体   English

在Asp.net中使用Response打印rdlc报告

[英]Print rdlc report using Response in Asp.net

    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)
{
}

This code use to download the pdf file.. but i want to print the file so output file opens to browser's print preview. 该代码用于下载pdf文件。但是我想打印该文件,因此输出文件将打开以浏览器的打印预览。 So anybody help to print a pdf file in browser....Thanks.... 因此,任何人都可以帮助在浏览器中打印pdf文件。

Thanks for posting this code. 感谢您发布此代码。 I just copied and pasted it into my application to successfully download a pdf to the browser. 我只是将其复制并粘贴到我的应用程序中,以将pdf成功下载到浏览器。 Your issue is very simple to fix. 您的问题很容易解决。 Change attachment; 更改附件; to inline; 内联; on the Response.AddHeader line. 在Response.AddHeader行上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM