private void btnPrint_Click(object sender, EventArgs e) { string _FileName = DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".pdf"; try { ReportDocument cryRpt = new ReportDocument(); cryRpt = (ReportDocument)crystalReportViewer1.ReportSource; ExportOptions exportOpts = new ExportOptions(); exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat; exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; ExportOptions CrExportOptions; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions(); CrDiskFileDestinationOptions.DiskFileName = ConfigurationManager.AppSettings.Get("PRINT_TEMP") + _FileName; CrExportOptions = cryRpt.ExportOptions; { CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; } cryRpt.Export(); System.Diagnostics.Process.Start(ConfigurationManager.AppSettings.Get("PRINT_TEMP") + _FileName); } catch(Exception Ex) { string msg = Ex.Message; MessageBox.Show("You Must Have a report viewable in the Report panel To print"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)