在我的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 中完成了相同的场景。在这里。