Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to create pdf file from crystal reports

Status
Not open for further replies.

Saturn57

Programmer
Aug 30, 2007
275
CA
I have a crystal report (quote)that is created based on a range of values used as crystal report parameters. I would like to have code to be able to generate an individual pdf file for each quote generated.
 
when I generate a pdf from crystal I use
Code:
var doc = new MyReport();
//set parameters
//set set data source
doc.ExportToFile(DocType.PDF, "name of file");
you may be able to print specific pages to pdf by configuring the print options (pages, etc.) if you don't get help here check out forum768.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Im not very experienced at this. I have never called the crystal report from code attached to anything like a button. I have only run it by using crystal reports viewer. Can you give me some insite.
 
the base class for crystal reports is ReportDocument. There are 2 ways to load reports.
1.
Code:
var doc = new ReportDocument();
doc.Load("path to report");
2.
Code:
var doc = new MyReport(); //which inherits ReportDocument
where MyReport is the name of a report within the solution(MyReport.rpt). VS IDE will auto-generate a MyReport.cs file.

now you have programmatic control of the report. There a few options for exporting the file
ExportToStream, ExportToDisk, ExportToHttp, or simply Export(with defined options). You can also control some of the print options. I'm not sure if/how the print options would effect the export options.

Documentation on CR for .net is limited at best. I also find the API is very limited. almost an after thought to incorporating crystal with .net.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top