When you want to export your Crystal Reports report to PDF format or any other format, this article provides guidance for exporting the Crystal Reports report to PDF format.
In this we can use ExportOptions for exporting the Crystal Reports report to PDF format. In the following example you can see how to export a Crystal Reports report as a PDF format file in C#. If you read my first article then it's easy to understand this example, if not then please read my first article.
Crystal Reports in C#
Just add the following code to export a Crystal Reports report to PDF or other format.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace CrystalReportDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnShow_Click(object sender, EventArgs e)
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"D:\C# Demos\Crystal Reports\CrystalReportDemo\CrystalReportDemo\CrystalReport1.rpt");
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();
cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"D:\ASD.pdf");
MessageBox.Show("Exported Successful");
}
}
}
In the code above we uesd the ReportDocument.ExportToDisk() function and in that the first parameter is the Export format type and the second parameter is the path to store the PDF file. Other options for exporting Crystal Reports to other formats are as follows:

You see that the other format options include:
- Excel
- ExcelRecord
- ExcelWorkbook
- NoFormat
- HTML32
- HTML40
- PortableDocumentFormat
- RichText
- Text
- XML
These are some of the other formats for exporting Crystal Reports in C#.
When you run the application click the Show button, it will ask for a username and password then it will show you the result in ReportViewer and then one message will be displayed, PDF Exported.


Here is your exported PDF:

Conclusion
In this article we learned how to export a Crystal Reports report in PDF or other format. I hope this example will help you to learn the basics of a C# Crystal Reports application and exporting a Crystal Reports report to another format.

Rakesh ChopadaPosted Jan 23, 2020, 1:56 PM
But how we can add parameter in this code ?
Martin NziokaPosted Apr 29, 2017, 2:13 PM
This " cryRpt.Load(@"D:\C# Demos\Crystal Reports\CrystalReportDemo\CrystalReportDemo\CrystalReport1.rpt");" works fine but when you deploy to clients, that path doesn't exist, so it fails to load. Can one have a report with a dynamic path or with the file path?
GokulPosted Jul 20, 2016, 5:09 AM
.
Praveen SPosted Mar 17, 2016, 4:25 AM
doc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"D:\test.pdf"); I am getting the following error in the above line of code Missing parameter value
Rahul SinghPosted Sep 29, 2015, 6:40 AM
code not working
Abdul-Aziz SesayPosted Jan 28, 2015, 11:59 AM
How do I get around this, need help ASAP
Abdul-Aziz SesayPosted Jan 28, 2015, 11:58 AM
Method not found: 'CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag CrystalDecisions.ReportAppServer.ReportDefModel.ISCRExportOptions.get_ExportOptionsEx()'.
Abdul-Aziz SesayPosted Jan 28, 2015, 11:58 AM
Hi. I've used you code but I keep getting the following error message
arun aPosted Aug 20, 2014, 6:49 AM
no need to ask username and password!.what can i do?
Jeetendra GundPosted Feb 21, 2014, 10:58 AM
what msg it is thrown...Please write for me?
Angel PrincessPosted Feb 21, 2014, 2:37 AM
crystalReportViewer1.ReportSource giving Error