Solved

crystal reports to show in PDF format

Posted on 2007-12-06
6
1,045 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 69

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now