Exporting a report to pdf
I am getting the following error when I try to export a report to pdf.
The process we are following is -
1. First we generate a report and store it in DB as a Document Blob.
2. When we want to view it, we write this DocumentBlob to the disk.
3. We then export this rpt to a pdf on disk.
This process is working fine until we change the layout of the crystal report.
I added a fake page header to the sub report, removed the already existing header from the sub report and am using the existing fields and not added any new fields.
When the layout is changed and a new report is generated, export to pdf is working fine.
But if we try to view an already existing report with the new layout then during Step 3, we are getting the following error.
Missing parameter field current value.
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details:CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException: Missing parameter field current value.
Source Error:
Line 125: diskOpts.DiskFileName = InvoicePDFPath + fileName; Line 126: Invoice1.ExportOptions.DestinationOptions = diskOpts;Line 127: Invoice1.Export();Line 128: Invoice1.Close(); Line 129: return fileName; |
Source File:c:\inetpub\wwwroot\ic\viewercontrol.ascx.cs Line:127
Stack Trace:
[ParameterFieldCurrentValueException: Missing parameter field current value.]
. F(String , EngineExceptionErrorID
) +574
CrystalDecisions.CrystalReports.Engine.FormatEngine.internalSetReportInfo(RequestContext reqContext) +1294
CrystalDecisions.CrystalReports.Engine.FormatEngine.internalGetViewContext(ReportPageRequestContext reqContext, * viewContext) +217
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext) +235
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export() +107
CrystalDecisions.CrystalReports.Engine.ReportDocument.Export() +67
ViewerControl.ExportToDisk() in c:\inetpub\wwwroot\ic\viewercontrol.ascx.cs:127
ViewerControl.LoadInvoice() in c:\inetpub\wwwroot\ic\viewercontrol.ascx.cs:49
ViewerControl.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\ic\viewercontrol.ascx.cs:23
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
The code we are using for exporting to pdf is -
CrystalDecisions.CrystalReports.Engine.ReportDocument Invoice1 =
new ReportDocument();Invoice1.Load(InvoiceRPTPath + outputFileName);
string fileName = outputFileName.Substring(0,3) + DateTime.Now.ToString("MMddyyHHmmssfff") + ".pdf";
DiskFileDestinationOptions diskOpts =new DiskFileDestinationOptions();
Invoice1.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
Invoice1.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
diskOpts.DiskFileName = InvoicePDFPath + fileName;
Invoice1.ExportOptions.DestinationOptions = diskOpts;
Invoice1.Export();
Invoice1.Close();
Thanks,
Deepti

