Pages

Showing posts with label PDF. Show all posts
Showing posts with label PDF. Show all posts

Thursday 18 June 2015

Code to EXPORT crystalreport to PDF

Introduction: In this article I will explain how to save the CrystalReport as PFD file. Saving pdf format of crystalreports is very important to keep the record.

Code :
Here is the complete code:

try
            {
                if (!Directory.Exists("D:\\Sanjeev\\"))
                {
                    Directory.CreateDirectory("D:\\Sanjeev\\");
                }
                ExportOptions CrExportOptions;
                DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
                CrDiskFileDestinationOptions.DiskFileName = "D:\\Sanjeev\\newpdf.pdf";
                CrExportOptions = b.ExportOptions;
                {
                    CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                    CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                    CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                    CrExportOptions.FormatOptions = CrFormatTypeOptions;
                }
                b.Export();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }