Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1063
  • Last Modified:

crystal reports to show in PDF format

Hi,
How to show crystal reports in pdf .
i am using crystal report viewer to show the reports now.
here is my code ,which i am using now.

using crystal reports 9/.net 1.1/c#
Thank you
public CrystalReport1 rpt = new CrystalReport1();
 
private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(dataSet11,"produ");
CrystalReportViewer1.ReportSource = rpt;
rpt.SetDataSource(dataSet11);
}

Open in new window

0
tag_k
Asked:
tag_k
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
habibbCommented:
you can use following code to show report to pdf formate instead of in viewer.

Dim CR as New  ReportDocument
..
..' provide path to open the report and enter parameters here too.

With CrExportOptions
        ' Set the destination to a disk file
      .ExportDestinationType = ExportDestinationType.DiskFile
      ' Set the format to PDF
      .ExportFormatType = ExportFormatType.PortableDocFormat
      ' Set the destination options to DiskFileDestinationOptions object
      .DestinationOptions = CrDiskFileDestinationOptions
      .FormatOptions = CrFormatTypeOptions
End With
' Export the report to the PDF folder path
CR.Export()

can use this code in click event of button control
0
 
stcindiaCommented:
Codes attached for ASP.NET (VB) pasted from my live project, this should help solve your problem.

Dim mem As MemoryStream
mem = rpt.ExportToStream(ExportFormatType.PortableDocFormat)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.BinaryWrite(mem.ToArray)
Response.End()

Open in new window

0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
tag_kAuthor Commented:
Thanks everyone but anyone can code it in c#/asp.net 1.1

thanks
0
 
stcindiaCommented:
Try using this and revert.
public CrystalReport1 rpt = new CrystalReport1();
 
private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(dataSet11,"produ");
CrystalReportViewer1.ReportSource = rpt;
rpt.SetDataSource(dataSet11);
        MemoryStream mem;
        mem= (MemoryStream) rpt.ExportToStream(ExportFormatType.PortableDocFormat);
        Response.Clear();
        Response.Buffer = true;
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(mem.ToArray());
        Response.End();
}

Open in new window

0
 
tag_kAuthor Commented:
Thanks StcIndia,
Just changed as below and working fine.
mem= (MemoryStream) rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now