Solved

crystal reports to show in PDF format

Posted on 2007-12-06
6
1,052 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add a step to a system backup job 6 15
RAISERROR WITH NOWAIT 2 14
RESTORE MASTER DATABASE -- NOW 2 15
SQL Recursion 6 16
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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.

792 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