.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

how to export crystal report in pdf file by default using C#

Posted By: Naim Khan     Posted Date: May 20, 2010    Points:2   Category :C#
hi friends,

we are using the crystal reports that comes with Visual studio 2005 for developing a c# windows application. we need to make the pdf the default export format for report. can anyone tell me how this can be done.

Thanks
Naim Khan

Responses
Author: Lalij Mer             
Posted Date: May 20, 2010     Points: 5   

you can try this code sample

using System;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
ReportDocument cryRpt;

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
cryRpt = new ReportDocument();
cryRpt.Load(PUT CRYSTAL REPORT PATH HERE\\CrystalReport1.rpt");
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();
}

private void button2_Click(object sender, EventArgs e)
{
try
{
ExportOptions CrExportOptions ;
DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
CrDiskFileDestinationOptions.DiskFileName = "c:\\csharp.net-informations.pdf";
CrExportOptions = cryRpt.ExportOptions;
{
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
CrExportOptions.FormatOptions = CrFormatTypeOptions;
}
cryRpt.Export();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}

}

For Reference
http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-export-pdf.htm

Please Check my answer if you help....
Thank You...

Lalit.
Author: BangaruBabuPureti             
Posted Date: May 22, 2010     Points: 5   

Hi Khan ,There is no need to Write manual coding to export PDF Document if u Place Crystal Report Viewer

it will automatically Populate PDF WIth Left Side icons

BangaruBabu Pureti
http://bangarubabupureti.spaces.live.com/
Author: arronlee             
Posted Date: October 17, 2015     Points: 20   

Hi Khan,
I wonder how can I deal with those codes? Do I need another pdf conversion sdk like this one?
http://www.pqscan.com/pdf-to-image/

Next Tomorrow is Another Day .


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend