I am using a ASP.net(
VB) application to run and export a PDF on the fly. My problem is that I want to embed a eWASP barcode font into the PDF but using its StringtoBC() conversion function. This function I can to run in the report itself.
So I want to:
-Run the report then..
-Before it exports to PDF, change the font for one of the fields but I dont think this can be done using one of the Crystal components.
Here is my current code:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Web
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.ViewerObjectModel
Imports CrystalDecisions.ReportSource
Public Class ReportViewer
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<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
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim reportName As String = Request.QueryString("rptName")
Dim paramName As String = Request.QueryString("paramName")
Dim paramVal As String = Request.QueryString("paramVal")
Try
StreamReport(reportName, paramName, paramVal)
Catch ex As Exception
End Try
End Sub
Private Sub StreamReport(ByVal reportName As String, ByVal paramName As String, ByVal paramVal As String)
'Define the Correct Crystal Report Variables
Dim report As ReportDocument
Dim rExportOptions As ExportOptions
Dim rDiskDestination As DiskFileDestinationOptions
Dim tmpFName As String
Dim sLocalPath As String = Server.MapPath("reports/" + reportName)
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterValues As New ParameterValues()
Dim str As String
Try
'Response.Write(sLocalPath)
'Response.End()
report = New ReportDocument()
report.Load(sLocalPath)
report.Refresh()
'Get the collection of parameters from the report
crParameterFieldDefinitions = report.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item(paramName)
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = paramVal
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crPa rameterValues)
'Setup the Export Location
tmpFName = "d:\exports\" + Session.SessionID.ToString + ".pdf"
'Set the Server to Write the File Locally
rDiskDestination = New DiskFileDestinationOptions()
rDiskDestination.DiskFileName = tmpFName
'Setup the Connection
Dim crConnectionInfo As New ConnectionInfo()
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
With crConnectionInfo
.DatabaseName = ""
.Password = "dba"
.ServerName = "DB.WORLD"
.UserID = "dba"
End With
crDatabase = report.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
rExportOptions = report.ExportOptions
With rExportOptions
.DestinationOptions = rDiskDestination
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
'''''''This is where I am assuming the convertion to barcode would take place''''''''''''''''''
report.Export()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(tmpFName)
Response.Flush()
Response.Close()
Session("IsDone") = "Y"
System.IO.File.Delete(tmpFName)
report.Close()
report.Dispose()
Catch ex As Exception
Response.Write(ex.Message)
Response.Write(ex.InnerException)
End Try
End Sub
End Class