I want to make a report from ASP.Net, in Crystal Report. I want, when user click on print, it should simply show a browser dialog of Save,Open,Save as, and PDF should be saved, or Crystal Report print preview should appear, I don't want to display report first in Viewer then click on button to get print or PDF, I want simply from clicking on asp button, I have all the idea of parameters and know how to make report, my question is just to not to show viewer and take report from asp button in a form of PDF or print preview dialog to print. I have used the Export method of .Net for Crystal Report, but it does not work.
You can generate a PDF by Using a Crystal Report and piece of code.
Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared
Dim CrReport As New CrystalReport1() // Report Name Dim CrExportOptions As ExportOptions Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions() Dim CrFormatTypeOptions as New PdfRtfWordFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = "c:\RichText.pdf"
crFormatTypeOptions.FirstPageNumber = 1 // Start Page in the Report crFormatTypeOptions.LastPageNumber = 3 // End Page in the Report crFormatTypeOptions.UsePageRange = True
CrExportOptions = crReport.ExportOptions With CrExportOptions // Set the destination to a disk file .ExportDestinationType = ExportDestinationType.DiskFile // Set the format to PDF .ExportFormatType = ExportFormatType.PortableDocFormat // Set the destination options to DiskFileDestinationOptions object .DestinationOptions = CrDiskFileDestinationOptions .FormatOptions = crFormatTypeOptions End With
Try // Export the report CrReport.Export() Catch err As Exception MessageBox.Show(err.ToString()) End Try
Thats it. Now you are ready to create a PDF of the Report.