Need help to export crystal report to PDF format

Asked By 10 points N/A Posted on -
qa-featured

Hello guys. I need some help and tips on how to export crystal report to pdf format and have it directly saved at the local folder of our website and then have it as an email attachment sent viat SMTP. So far I have only succeeded in the conversion to pdf but couldn’t have it saved in the destination folder, and failed in the attachment via SMTP code too. Any ideas?

SHARE
Best Answer by Toni Linscomb
Answered By 0 points N/A #135759

Need help to export crystal report to PDF format

qa-featured

Hi friend,

You can convert any Crystal Report to a PDF. This can help when you need to e-mail a report to someone who does not have Crystal Report. You must have Adobe Acrobat installed on your computer to export a PDF. You may download a free version of Adobe Reader from this site.

Best Answer
Best Answer
Answered By 5 points N/A #135760

Need help to export crystal report to PDF format

qa-featured

 

Using below method written in C#, you can export crystal report into PDF format and save it into physical location.

 

Private void exportReport()

{

//Create new report object

 ReportDocumentcrystalReport = new ReportDocument();

// Load the crystal report

 crystalReport.Load(Server.MapPath("~/Reports/Archive/ArchiveReport.rpt")); 

// Assign a datasource for the report                     

crystalReport.Database.Tables["tblArchive"].SetDataSource(dtReportData);

//Show the report on the crystal report viewer

CrystalReportViewer1.ReportSource = crystalReport;

//Export to disk

crystalReport.ExportToDisk(ExportFormatType.PortableDocFormat, "E:\Report.pdf");

}

Now you have the PDF files saved on the disk and now you can attached it to a SMTP email. Try below links to see how to do a SMTP attachment

http://csharp.net-informations.com/communications/csharp-email-attachment.htm

https://www.codeproject.com/Articles/10828/Sending-Email-with-attachment-in-ASP-NET-using-SMT

Related Questions