Solved

crystal reports to show in PDF format

Posted on 2007-12-06
6
1,051 Views
Last Modified: 2013-11-26
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
Comment
Question by:tag_k
6 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 20421408
0
 
LVL 4

Expert Comment

by:habibb
ID: 20426942
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
 
LVL 4

Expert Comment

by:stcindia
ID: 20433163
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:tag_k
ID: 20437496
Thanks everyone but anyone can code it in c#/asp.net 1.1

thanks
0
 
LVL 4

Accepted Solution

by:
stcindia earned 500 total points
ID: 20440501
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
 

Author Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question