protected string generateInvoicePDF(int invoiceID) { string reportPath = null; string appPath = ConfigurationManager.AppSettings["appPath"].ToString(); invoiceReport = LeadInvoiceManager.GetInvoiceForReport(invoiceID); if (invoiceReport != null) { reportViewer.Reset(); reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.EnableExternalImages = true; ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "DataSet1"; reportDataSource.Value = invoiceReport; reportViewer.LocalReport.DataSources.Add(reportDataSource); reportViewer.LocalReport.ReportPath = appPath + "/Content/Invoice.rdlc"; reportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(subReportsEventHandler); reportPath = string.Format("{0}/Temp/Invoice_{1}.pdf", appPath, invoiceID); Core.ReportHelper.savePDFFromLocalReport(reportViewer.LocalReport, reportPath); } return(reportPath); }
protected void Page_Load(object sender, EventArgs e) { int invoiceID = Request.Params["id"] == null ? 0 : Convert.ToInt32(Request.Params["id"]); invoice = LeadInvoiceManager.GetInvoiceForReport(invoiceID); if (invoice != null) { reportViewer.Reset(); reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.EnableExternalImages = true; ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "DataSet1"; reportDataSource.Value = invoice; reportViewer.LocalReport.DataSources.Add(reportDataSource); reportViewer.LocalReport.ReportPath = appPath + "/Content/Invoice.rdlc"; this.reportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(subReportsEventHandler); string pdfPath = string.Format("{0}/Temp/{1}.pdf", appPath, Guid.NewGuid()); Core.ReportHelper.savePDFFromLocalReport(reportViewer.LocalReport, pdfPath); Core.ReportHelper.renderToBrowser(pdfPath); } }