0

在我的ASP.NET MVC3(Razor)应用程序中,我正在努力解决print utility. 我想auto print a PDF file which is converted from rdlc

我使用以下代码将 rdlc 转换为 pdf:

        LocalReport localReport = new LocalReport();

        localReport.ReportPath = @"Reports/OP/Rdlc/ClinicInvoiceReceipt.rdlc";

        iClinicInvoiceReceipt = new RmtOPInvoice.ClinicInvoiceReceipt();
        DataTable dt = iClinicInvoiceReceipt.SelectReceiptDtlForPrint(1);

        ReportDataSource reportDataSource = new ReportDataSource();
        reportDataSource.Value = dt;
        reportDataSource.Name = "DataSet1";
        localReport.DataSources.Add(reportDataSource);

        string reportType = "PDF";
        string mimeType;
        string encoding;
        string fileNameExtension;

        string deviceInfo =
         @"<DeviceInfo>
            <OutputFormat>PDF</OutputFormat>
            <PageWidth>5.83in</PageWidth>
            <PageHeight>8.27in</PageHeight>
            <MarginTop>0in</MarginTop>
            <MarginLeft>0.in</MarginLeft>
            <MarginRight>0in</MarginRight>
            <MarginBottom>in</MarginBottom>
        </DeviceInfo>";
        Warning[] warnings;

        string[] streams;

        byte[] renderedBytes;

        renderedBytes = localReport.Render(
           reportType,
           deviceInfo,
           out mimeType,
           out encoding,
           out fileNameExtension,
           out streams,
           out warnings);

        return File(renderedBytes, "application/pdf");

我想同时在视图上显示这个open the print dialog of pdf viewer automaticaly

我只是在这里将 javscript 转换为 pdf 。但是我对在我上面的代码中实现这一点感到困惑。如果有人经历过这个,请分享。这对我真的很有帮助。

我刚刚发现在 PHP 中完成了相同的场景。在这里

4

2 回答 2

1

也许我找到的这个答案很有帮助

  1. 它是 ASP.NET MVC
  2. 它直接流式传输 RDLC 响应

http://weblogs.asp.net/rajbk/archive/2009/11/25/rendering-an-rdlc-directly-to-the-response-stream-in-asp-net-mvc.aspx

于 2013-02-03T20:34:57.940 回答
-1

我实现了这个使用iTextSharp

是我做的示例项目。

于 2013-04-03T12:01:05.493 回答