Export Crystal Report to PDF and open it in Acrobat Reader instead of Internet Explorer


D

Dave

Is this possible? Here is my current code (which opens the pdf in Internet
Explorer)

Dim crReportDocument As
CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim crExportOptions As CrystalDecisions.shared.ExportOptions
Dim crDiskFileDestinationOptions As
CrystalDecisions.shared.DiskFileDestinationOptions
Dim Fname As String
crReportDocument = New
CrystalDecisions.CrystalReports.Engine.ReportDocument
crReportDocument.Load("C:\Inetpub\wwwroot\SAFDB\JobHoursReport.rpt")
Try
Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo

For Each tbCurrent In crReportDocument.Database.Tables
tliCurrent = tbCurrent.LogOnInfo
With tliCurrent.ConnectionInfo
.ServerName = "NOVAPRJ"
.UserID = "sa"
.Password = "sa"
.DatabaseName = "NSSApplication"
End With
tbCurrent.ApplyLogOnInfo(tliCurrent)
Next tbCurrent
Catch ex As Exception
Response.Write(ex.Message)
Finally
End Try

Dim StartYear As Integer
Dim StartMonth As Integer
Dim StartDay As Integer
Dim EndYear As Integer
Dim EndMonth As Integer
Dim EndDay As Integer

crReportDocument.Refresh()
Fname = "c:\Reports\" & Session.SessionID.ToString & ".pdf"
crDiskFileDestinationOptions = New
CrystalDecisions.shared.DiskFileDestinationOptions
crDiskFileDestinationOptions.DiskFileName = Fname
crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType =
CrystalDecisions.Shared.ExportDestinationType.DiskFile
.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
End With
crReportDocument.Export()
' The following code writes the pdf file to the Client's browser.
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
'Response.WriteFile(Fname)
Response.Redirect(Fname)
Response.Flush()
Response.Close()
Response.ClearContent()
Response.End()
System.IO.File.Delete(Fname)
crReportDocument.Close()
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top