Crystal Report convert into PDF

Posted by Senthilmcatyr under VB.NET on 7/29/2011 | Points: 10 | Views : 11902 | Status : [Member] | Replies : 10
Hi,
I create crystal report in vb.net. I need automatically open pdf file on click open button. Pls solve it early as possible.

Regards,
SenthilKumar.S




Responses

Posted by: Lalji_mer on: 7/29/2011 [Member] Bronze | Points: 25

Up
0
Down
refer below link

http://www.codeproject.com/KB/vb/Crystal_Reports_To_PDF.aspx

LP MER

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: RaviRanjanKr on: 7/31/2011 [Member] Starter | Points: 25

Up
0
Down
Try
http://codebetter.com/petervanooijen/2004/02/11/exporting-from-crystal-reports-to-pdf-word-excel-and-html/


Thanks
Ravi Ranjan Kumar
http://raviranjankr.wordpress.com

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Arunvasu on: 1/30/2012 [Member] Starter | Points: 25

Up
0
Down
use this code after create crystal report file

If emailid.Trim().Length > 0 Then
CRSource.ReportDocument.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
CRSource.ReportDocument.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
rptExportType = "PDF"
fileExtension = "pdf"
CRSource.ReportDocument.ExportOptions.DestinationOptions = destOptions
CRSource.ReportDocument.Export()

Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
Dim path As String = Server.MapPath("temp/")
Dim writepath As String = path & "." & "Dolphin_EbookSearchResult.pdf"
Response.AddHeader("Content-Type", rptExportType)
Response.AddHeader("Content-Disposition", "attachment; filename=" + destOptions.DiskFileName & "." & fileExtension)


Dim fs As New FileStream(destOptions.DiskFileName, FileMode.Open)
Dim fileSize As Long = fs.Length
Dim bBuffer As Byte() = New Byte(System.Convert.ToInt32(fileSize) - 1) {}
fs.Read(bBuffer, 0, System.Convert.ToInt32(fileSize))

File.WriteAllBytes(writepath, bBuffer)
fs.Close()


email_recordset.SendEbookDetails(emailid, writepath)
Response.Redirect("NewE-Search.aspx")


End If


if you need to display pdf file the replace File.WriteAllBytes(writepath, bBuffer) code with response.bufferwrite(bBuffer)

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bluedaisy3294 on: 2/15/2012 [Member] Starter | Points: 25

Up
0
Down
Sorry for that .I suggest you to go to the micrsoft service for help.http://support.microsoft.com/Hope everything will come back soon.And you may download a Barcode Generator for .NET Crystal Reports to make your own barcode so as to make sure your printer is ok again.http://www.keepautomation.com/products/net_barcode_crystal_reports/barcodes/upca.html

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blueskysinger on: 2/21/2012 [Member] Starter | Points: 25

Up
0
Down
Hey,since you're talking about PDF here, I might as well give some suggestions. Here'sPDF417 barcode scanner I've been using, very convenient, and supports 20+ major barcode types~de Reader
http://www.keepautomation.com/products/net_barcode/barcodes/pdf_417.html

Anna White

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Daisywhite on: 2/23/2012 [Member] Starter | Points: 25

Up
0
Down
Sorry for nothing to do ,but a crystal barcode generator might be helpful.http://www.keepautomation.com/products/net_barcode_crystal_reports/barcodes/code_128.html

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Stevnetk on: 3/13/2012 [Member] Starter | Points: 25

Up
0
Down
For reporting to pdf I recommend this very helpful article:
http://www.nopcommerce.com/boards/t/15568/feature-request-template-based-reporting-system.aspx

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandeepkasar on: 4/12/2012 [Member] Starter | Points: 25

Up
0
Down
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Windows.Forms
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports System.IO
Imports System.Data.SqlClient
Imports System.Diagnostics.Process


Public Class Reports
#Region "Variables"
Private printFont As Font
Private streamToPrint As StreamReader
Dim cryRpt As ReportDocument
Dim FromDate, ToDate As Date
Dim RptDate As Date = Nothing
Dim Tit As String = ""
Dim Cn As New SqlConnection(ConStr)
Dim defaultPrinterName As String = ""
Dim setPaperSize As Short = 9 'A4
Dim setPaperOrientation As Short = 1 ' portail

#End Region

#Region "Report"

Public Sub AcMastReport()
Try
cryRpt = New ReportDocument
Tit = "Account Master Report"
RptFile("AcMasterRpt")
LoadReport(PaperSize.PaperA4, PaperOrientation.Portrait)
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub


#End Region

#Region "FixMethods"


Private Sub PDFExport()
Try
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = (My.Application.Info.DirectoryPath & "\PDF.pdf")
CrExportOptions = cryRpt.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
cryRpt.Export()
RDFLoad()
Catch ex As Exception
MsgBox("Pdf Export Fails")
End Try
End Sub

Private Sub RDFLoad()
Try
Dim GetPrint As New Process
GetPrint.StartInfo.FileName = (My.Application.Info.DirectoryPath & "\PDF.pdf")
GetPrint.Start()
Catch ex As Exception
MsgBox("Pdf file is not present", MsgBoxStyle.Information)
End Try
End Sub


Private Sub Authetication()
SetLocation() 'dynamically changes rpt location
'cryRpt.SetDatabaseLogon(UserIdString, UserPasswordString, DSNString, Cn.Database) 'not requried for DSn with Win Nt authetication
End Sub

Private Sub SetLocation()
Dim LgInfo As New TableLogOnInfo
Dim TS As CrystalDecisions.CrystalReports.Engine.Tables = cryRpt.Database.Tables
For Each tb As CrystalDecisions.CrystalReports.Engine.Table In TS
LgInfo = tb.LogOnInfo
With LgInfo.ConnectionInfo
.ServerName = DSNString
.DatabaseName = Cn.Database
'.UserID = UserIdString 'not requried for DSn with Win Nt authetication
'.Password = UserPasswordString 'not requried for DSn with Win Nt authetication
End With
tb.ApplyLogOnInfo(LgInfo)
tb.Location = Cn.Database & ".dbo." & tb.Name
Next
End Sub

Private Sub LoadReport(ByVal PZ As PaperSize, ByVal PO As PaperOrientation)
Authetication()
setPaperSize = PZ
setPaperOrientation = PO
If PDF_Format = 0 Then
cryRpt.PrintOptions.PaperSize = PZ
cryRpt.PrintOptions.PaperOrientation = PO
CRV1.ReportSource = cryRpt
CRV1.Refresh()
Else
PrinterSettings()
PDFExport()
End If
End Sub

Private Sub RptFile(ByVal RptFileName As String)
RptFileName = "\" & RptFileName & ".rpt"
cryRpt.Load(My.Application.Info.DirectoryPath & RptFileName.Trim)
End Sub

#End Region
End Class

This will surely works

Sandeep



Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/12/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Senthil,
can u refer this link step by step process is there.
http://vb.net-informations.com/crystal-report/vb.net_crystal_report_export_pdf.htm

Thanks & Regards
Hari

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Longwest on: 6/26/2015 [Member] Starter | Points: 25

Up
0
Down
Many tutorials can be easy found.
Such as this one:
http://www.codeproject.com/Tips/716161/How-to-Export-Crystal-Report-on-Button-Click-in-to

Beast regards.
http://www.businessrefinery.com/

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response