Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2004, 09:22 AM
Authorized User
 
Join Date: Oct 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Crystal Report Export to PDF with embedded Barcode

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

 
Old June 12th, 2004, 05:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

im sure u'll find someting to help u at: http://www.businessobjects.com/produ...hnical.asp#net
&
http://p2p.wrox.com/topic.asp?TOPIC_ID=6389

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Export Crystal Report to PDF aarunlal ASP.NET 2.0 Professional 1 June 28th, 2006 01:18 PM
Export to PDF problem with crystal report in c# fidelio ASP.NET 1.0 and 1.1 Professional 0 April 12th, 2006 07:34 AM
facing problem to export crystal report to PDF whi agarwal Beginning VB 6 0 November 12th, 2005 06:57 AM
Crystal Report 8.5 Export to PDF problem DragonSon Crystal Reports 0 August 17th, 2004 10:32 PM
Pdf Crystal Report export Kristoff Crystal Reports 1 October 21st, 2003 09:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.