Mark White

Mark White

  • NA
  • 2
  • 1.1k

Exporting to PDF of crystal report throws Exception

Jan 19 2017 12:14 AM
Hi,
I am trying to Export crystal Report to PDF and tried numerous steps you can refer my other posts HERE: https://www.codeproject.com/Questions/1165812/Exporting-crystal-report-to-PDF-gives-missing-para
 but none of them worked. Recently I tried using this code:
 
  1. cryRpt = new ReportDocument();  
  2.               cryRpt.Load("E:\\Office\\Clients\\Bombay Restaurant\\Banquet New - MySql\\Banquet New\\RPTBanQoute.rpt");  
  3.               crystalReportViewer1.ReportSource = cryRpt;  
  4.               crystalReportViewer1.Refresh();  
  5.               try  
  6.               {  
  7.                   ExportOptions CrExportOptions;  
  8.                   DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();  
  9.                   PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();  
  10.                   CrDiskFileDestinationOptions.DiskFileName = "c:\\csharp.net-informations.pdf";  
  11.                   CrExportOptions = cryRpt.ExportOptions;  
  12.                   {  
  13.                       CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;  
  14.                       CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;  
  15.                       CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;  
  16.                       CrExportOptions.FormatOptions = CrFormatTypeOptions;  
  17.                   }  
  18.                   cryRpt.Export();  
  19.               }  
  20.               catch (Exception ex)  
  21.               {  
  22.                   MessageBox.Show(ex.ToString());  
  23.               }  
But this gave me an exception :
 
 
So what am I dong wrong , I am also passing around 4 parameters to this RPT