Solved

crystal reports to show in PDF format

Posted on 2007-12-06
6
1,055 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
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.

626 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