ASP.NET Crystal Report Question

H

Hero Ngan

The following code is export the Crystal Report to PDF format on the server
side, then display on the client browser.
Question: How can prompt the PDF's "Print" dialog box, when the PDF was open
completed on the browser.
Thank you for help!

Rdgs,
Hero Ngan

***********************************************************************
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web.Design

Public Class WebForm1
Inherits System.Web.UI.Page

#Region " Web Form"
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim oRpt As New ReportDocument()
Dim crLogOnInfo As New TableLogOnInfo()

Dim ex As New ExportRequestContext()
Dim s As New System.IO.MemoryStream()
Dim exOption As New ExportOptions()

oRpt.Load("C:\Inetpub\wwwroot\homepage\CrystalReport\Report1.rpt")

With crLogOnInfo.ConnectionInfo
.ServerName = "xxx.xxx.xxx.xxx"
.DatabaseName = "db"
.UserID = "xxxxx"
.Password = "xxxxxxx"
End With

Dim ReportDatabase As Database
Dim dbTables As Tables
Dim dbTable As Table

' Creates the Database object
ReportDatabase = oRpt.Database

' Set logon information for each table in the report
dbTables = ReportDatabase.Tables
For Each dbTable In dbTables
dbTable.ApplyLogOnInfo(crLogOnInfo)
Next

exOption.ExportFormatType = ExportFormatType.PortableDocFormat
ex.ExportInfo = exOption

s = oRpt.FormatEngine.ExportToStream(ex)

With HttpContext.Current.Response
.ClearContent()
.ClearHeaders()
.ContentType = "application/pdf"
.AddHeader("Content-Disposition", "inline;
filename=Report1.pdf")
.BinaryWrite(s.ToArray)
.End()
End With

End Sub

End Class
***********************************************************************
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top