Click here to Skip to main content
Licence 
First Posted 28 Jun 2006
Views 96,922
Bookmarked 28 times

Convert a Crystal Report to PDF

By | 25 Jun 2007 | Article
Export a report to PDF at runtime (Dynamically)

Introduction

Export a report to PDF at runtime (Dynamically)

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Jats_4ru

Web Developer

India India

Member

Software Developer

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralReally Helpful PinmemberAnandaB5:46 26 May '12  
QuestionHi PinmemberJoannou H. Fegarido19:50 29 Feb '12  
GeneralMy vote of 5 PinmemberCharles Mutts0:36 17 Nov '11  
GeneralNot able to download the entire solution PinmemberShivprakash Pandey22:17 19 Mar '11  
GeneralMy vote of 1 Pinmemberkamlesh88518:13 12 Jan '10  
GeneralWorked! PinmemberMargaretShepherd5:18 4 Aug '09  
GeneralRe: Worked! PinmemberMember 149357021:06 1 Sep '11  
Generalthank you PinmemberLevi Erdmann11:41 13 Feb '09  
Answeranother way Pinmemberdespotovic1:20 5 Dec '08  
GeneralExport a report to PDF at runtime (Dynamically) PinmemberMember 45705182:49 24 Sep '08  
GeneralThis code doesn't work Pinmemberprashantds12:40 17 Jul '08  
QuestionCompiler Error Message: BC30002: Type 'CrystalReport1' is not defined PinmemberTim Vandeweerd6:58 19 May '08  
GeneralHelp Pls PinmemberSuresh Kumar.A23:02 8 Mar '08  
GeneralThanks a lot! Pinmemberpmartike1:06 11 Sep '07  
GeneralThanks Pinmemberfazo22:07 21 Sep '06  
GeneralI hate to critisize people PinmemberEnnis Ray Lynch, Jr.7:25 28 Jun '06  
GeneralAnd yes PinmemberEnnis Ray Lynch, Jr.7:26 28 Jun '06  
QuestionWhat Article ? PinmemberDarka1:54 28 Jun '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120528.1 | Last Updated 26 Jun 2007
Article Copyright 2006 by Jats_4ru
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid