【发布时间】:2013-01-16 16:19:13
【问题描述】:
在我的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 here。但是我对在我上面的代码中实现这一点感到困惑。如果有人经历过这个,请分享。这对我真的很有帮助。
我刚刚发现在 PHP 中完成了相同的场景。 Here.
【问题讨论】:
-
您对网络浏览器(或 PDF 插件)的运行方式没有太多控制权。
-
该引用是 Acrobat 特定的实现 - 这被视为安全风险。
标签: c# javascript asp.net-mvc-3 pdf-generation acrobat-sdk