Exporting a Crystal Report directly to PDF

D

DBM

I am trying to export a report generated using Crystal Reports for .Net
directly to a PDF file without requiring any associated user interface. The
report does not directly query a database, but has an ADO dataset loaded
(there are also a couple of report parameters that get set during
configuration). Can any body point me to some examples that meet this need?

TIA

Brad
 
A

Aflava

Hi,


Did you tried something like this:


1.. CrystalDecisions.CrystalReports.Engine.ReportDocument doc = new
CrystalDecisions.CrystalReports.Engine.ReportDocument();
2.. doc.Load(@"d:\\fichier.rpt" );
3.. System.IO.Stream PDFOut = null;
4.. System.IO.FileStream PDFWriter = new
FileStream(@"d:\\fichier.pdf",FileMode.Create);
5.. PDFOut =
doc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
6.. PDFOut.Flush();
7.. PDFOut.Position = 0;
8.. BinaryReader reader = new BinaryReader(PDFOut);
9..
PDFWriter.Write(reader.ReadBytes((int)reader.BaseStream.Length),0,(int)reader.BaseStream.Length);
10.. PDFWriter.Flush();
11.. PDFWriter.Close();
 
D

DBM

Thank you for the response. I've tried this method and I've gotten the same
error message that I've gotten with other methods:

CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException:
Missing parameter values. ---> System.Runtime.InteropServices.COMException
(0x8004100E): Missing parameter values.

I've correctly loaded the parameters and the report is okay if I display it
using a report viewer control, but fails when I export. Any thoughts?

Thanks again.

Brad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top