views:

21

answers:

1

is there a library available for classic asp. I want to create a pdf file from rpt file in classic asp. i dont want to install crystal reports. is there a way?

-Vivek

+2  A: 

You can use only the Crystal Reports redistributable DLLs to open a report file and generate a PDF with it.

I've never tried to open the Crystal Reports library directly from ASP, but should be no problem (or you can create a COM Dll in VB6 if you can)

Some code I have in a VB6 DLL using Crystal Reports 9:

Private Sub Export(ReportFile as string)
    Dim crxReport As Report
    Set crxReport = Prepare(ReportFile )

    crxReport.ExportOptions.FormatType = crEFTPortableDocFormat
    crxReport.ExportOptions.DestinationType = crEDTDiskFile
    crxReport.ExportOptions.DiskFileName = "C:\export\export.pdf"
    crxReport.Export (False)
end sub


Private Function Prepare(ReportFile as string) As Report

    Dim CRapp As CRAXDRT.Application
    Set CRapp = New CRAXDRT.Application
    Dim crxReport As Report
    Dim aDatabaseObject As Database

    Dim aDatabaseTableObject As CRAXDRT.DatabaseTable
    Dim objConn As ConnectionProperty


    Set CRapp = New CRAXDRT.Application
    CRapp.SetLicenseKeycode ("XXXXXXXXXXXXXXXXXXXXXXXX")
    Set crxReport = CRapp.OpenReport(ReportFile)

    Set aDatabaseObject = crxReport.Database
    Set cnn = New ADODB.Connection
    cnn.ConnectionString = MyConnectionString()

    Set aDatabaseObject = crxReport.Database

    For Each aDatabaseTableObject In aDatabaseObject.Tables
        Dim objCPProperties As CRAXDRT.ConnectionProperties
        aDatabaseTableObject.DllName = "crdb_ado.dll"
        Set objCPProperties = aDatabaseTableObject.ConnectionProperties
        objCPProperties.DeleteAll
        objCPProperties.Add "Provider", "SQLOLEDB"
        objCPProperties.Add "Data Source", cnn.Properties.Item("Data Source").Value
        objCPProperties.Add "Initial Catalog", cnn.Properties.Item("Initial Catalog").Value
        objCPProperties.Add "User ID", cnn.Properties.Item("User ID").Value
        objCPProperties.Add "Password", cnn.Properties.Item("Password").Value
        aDatabaseTableObject.Location = aDatabaseTableObject.Name
    Next

    Set Prepare = crxReport

End Function
Eduardo Molteni