Click here to Skip to main content
15,891,787 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Export Crystal Reports to PDF file any body know help me
Posted
Comments
Abdul Quader Mamun 18-Feb-11 8:24am    
Where is you code?
Rupa1 18-Feb-11 8:26am    
protected void btnsearch_Click(object sender, EventArgs e)
{

SqlDataAdapter ad = new SqlDataAdapter("select * from customer where strdate BETWEEN '" + txtfrom.Text + "' AND '" + txtto.Text + "'", (SqlConnection)Application.Get("HR"));
DataSet ds = new DataSet();
ad.Fill(ds);
oRpt = new ReportDocument();
oRpt.Load(Server .MapPath ("~/Reports/CustomerRpt.rpt"));
oRpt.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = oRpt;

}
//pdf converting here
protected void Button1_Click(object sender, EventArgs e)
{
MemoryStream oStream=new MemoryStream (); // using System.IO
oStream = (MemoryStream)
oRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(oStream.ToArray());
Response.End();
}

Sunasara Imdadhusen 18-Feb-11 9:10am    
Did you try before?

Please try the following

C#
string FileName = "test.rpt";
           string FullPath = Path.Combine("ReportFolder", FileName);
           rptDoc.Load(Server.MapPath(FullPath));
           rptDoc.SetDataSource(dt);
           //Export to PDF
           ExportOptions CrExportOptions;
           DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
           PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
           CrDiskFileDestinationOptions.DiskFileName = "D:/GeneratedPDF/PDFFileName.pdf";
           CrExportOptions = rptDoc.ExportOptions;
           CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
           CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
           CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
           CrExportOptions.FormatOptions = CrFormatTypeOptions;
           rptDoc.Export(CrExportOptions);


Thanks,:rose::thumbsup:
Imdadhusen
 
Share this answer
 
Hope Export-Crystal-Reports-To-PDF[^] might help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900