C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Create pdf from crystal report


Posted Date: 22 Jun 2007    Resource Type: Code Snippets    Category: Crystal Reports

Posted By: Dilip Kumbhar       Member Level: Gold
Rating:     Points: 10



First create crystal report.In the interface of report i.e aspx form to display report,add report document as
Toolbox-->Components-->ReportDocument.
Call the sub routine CreatePDF to display report.
rptProduct is the name of crystal report and docProd is the name of report document.




Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO

'This call is required by the Web Form Designer.
Private Sub InitializeComponent()
'start - This code should be pasted under #Region Private Sub itializeComponent()
'rptProduct is the name of crystal report.
Me.docProd = New rptProduct
'
'docProd
'
Me.docProd.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.DefaultPaperOrientation
Me.docProd.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize
Me.docProd.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Upper
Me.docProd.PrintOptions.PrinterDuplex = CrystalDecisions.Shared.PrinterDuplex.Default
'Ends here

'Declaration of report document
Protected WithEvents docProd As rptProduct

Private Sub CreatePDF()
Dim objDS As New DataSet
Dim dfdoFile As New CrystalDecisions.Shared.DiskFileDestinationOptions
Dim strServerPath As String
Dim szFileName As String


'Create dataset as per requirement

docProd.SetDataSource(objDS.Tables(0))

szFileName = Session.SessionID & ".pdf" ' rptDailyCalls.pdf
strServerPath = MapPath("~") & "\Report\" ' Here the pdf file will be saved.
File.Delete(strServerPath & "\" & szFileName) ' Delete file first
dfdoFile.DiskFileName = strServerPath & "\" & szFileName
With docProd
.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
.ExportOptions.DestinationOptions = dfdoFile
.Export()
End With
'URL of the pdf file
Response.Redirect("http://localhost/WebApplication1/" & szFileName ,Flase)
End Sub






Responses

Author: Parshuram    17 May 2008Member Level: Gold   Points : 2
But By defult Crystal report open in pdf


Author: Kumar Velu    31 May 2008Member Level: Diamond   Points : 2
nice .. ,but change the title to export report to pdf..


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Convert a Crystal Report to Word
Previous Resource: Load Crystal Report from File
Return to Discussion Resource Index
Post New Resource
Category: Crystal Reports


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

Help Desk

Contact Us    Privacy Policy    Terms Of Use