Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi
I have one htm report and i want to convert it to pdf in page load event how to it possible
Thanks
Posted
Comments
JoCodes 10-Oct-13 3:11am    
What you meant by Html report???

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Shared.Interop;
using System.IO;


bool status = false;
DataTable dt = new DataTable();
Student stu=new Student();
dt = stu.getActiveBlockStudentReport(0,Convert.ToString(ddlDepartment.SelectedValue),Convert.ToString(ddlCourses.SelectedValue),Convert.ToString(ddlStatus.SelectedValue));
try
{
if (dt != null && dt.Rows.Count>0)
{
if (File.Exists(Server.MapPath("~/ActiveBlockStudent.Pdf")))
{
System.IO.File.Delete(Server.MapPath("ActiveBlockStudent.Pdf"));
}

string rptName = Server.MapPath("~\\Reports\\rptBlockActiveStudent.rpt");
ReportDocument RptDoc = new ReportDocument();
RptDoc.Load(rptName);
RptDoc.SetDataSource(dt);
ExportOptions exportOpts1 = RptDoc.ExportOptions;
RptDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
RptDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
RptDoc.ExportOptions.DestinationOptions = new DiskFileDestinationOptions();
((DiskFileDestinationOptions)RptDoc.ExportOptions.DestinationOptions).DiskFileName = Server.MapPath("ActiveBlockStudent.Pdf");
RptDoc.Export();
RptDoc.Close();
RptDoc.Dispose();
{
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=ActiveBlockStudent.Pdf");
Response.WriteFile("ActiveBlockStudent.Pdf");
Response.Flush();
Response.Close();
}
if (File.Exists(Server.MapPath("~/ActiveBlockStudent.Pdf")))
{
System.IO.File.Delete(Server.MapPath("ActiveBlockStudent.Pdf"));
}
status = true;
}
else
{
status = false;
}
}
catch (Exception ex)
{
status = false;
}
if (status == false)
{
Messagebox1.Show("No Record Found.");
}
 
Share this answer
 
Comments
[no name] 10-Oct-13 4:52am    
I say html report not a crystal report and i want to Without crystal report
 
Share this answer
 
 
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