![]() |
Languages »
VB.NET »
General
Intermediate
Convert a Crystal Report to PDFBy Jats_4ruExport a report to PDF at runtime (Dynamically) |
VB, .NET, Win2K, WinXP, Win2003, TabletPC, Visual Studio, Dev
|
||||||||||
|
Advanced Search |
|
|
|
||||||||||||||||
How to generate a report to PDF... I had this requirement and after my research i came up with this.
You can generate a PDF by Using a Crystal Report and piece of code....
First: Generate a Crystal Report as per your requirements.
Second: Use the below code to generate the PDF.
Place the following name spaces at the top of the code page
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Variable Declaration
Dim CrReport As New CrystalReport1() ' Report Name
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
Dim CrFormatTypeOptions as New PdfRtfWordFormatOptions()
Set the destination path and file name
CrDiskFileDestinationOptions.DiskFileName = "c:\RichText.pdf"
Specify a page range (optional)
crFormatTypeOptions.FirstPageNumber = 1 ' Start Page in the Report
crFormatTypeOptions.LastPageNumber = 3 ' End Page in the Report
crFormatTypeOptions.UsePageRange = True
Set export options
CrExportOptions = crReport.ExportOptions
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
Trap any errors that occur on export
Try
Export the report
CrReport.Export()
Catch err As Exception
MessageBox.Show(err.ToString())
End Try
Thats it.... Now you are ready to create a PDF of the Report.
Hope it will be useful...
Plz add your comments and suggestions about the Article.
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 25 Jun 2007 Editor: |
Copyright 2006 by Jats_4ru Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |