我正在尝试在aspx链接按钮上创建.pdf文件。以下是我的代码:
protected void lbtnInvoice_Click(object sender, EventArgs e)
{
List<InvoiceView> invoices = GetInvoices();
FastReport.Utils.Config.WebMode = true;
Report rep = new Report();
var path = @"PathToDataFileToBeUsedByReport\Report.Data";
rep.Load(path);
rep.RegisterData(invoices, "Invoice", FastReport.Data.BOConverterFlags.AllowFields, 2);
if (rep.Report.Prepare()) //Exception Thrown here!
{
FastReport.Export.Pdf.PDFExport pdfExport = new FastReport.Export.Pdf.PDFExport();
pdfExport.ShowProgress = false;
pdfExport.Subject = "Subject";
pdfExport.Title = "xxxxxxx";
pdfExport.Compressed = true;
pdfExport.AllowPrint = true;
pdfExport.EmbeddingFonts = true;
MemoryStream strm = new MemoryStream();
rep.Report.Export(pdfExport, strm);
rep.Dispose();
pdfExport.Dispose();
strm.Position = 0;
return File(strm, "application/pdf", "report.pdf");
}
}
但Object reference not set to an instance of an object
rep.Report.Prepare()
非常感谢任何帮助。
修改:我将rep.Report.Prepare()
替换为rep.Prepare()
时出现同样的错误,在这种情况下我知道rep
不为空。