By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,417 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,417 IT Pros & Developers. It's quick & easy.

PDF export of a Crystal Report in a webform

P: n/a
Hi all,

I have been suffering with this problem for weeks now. I tried several
newsgroups, but nobody can tell me how to solve this problem. The problem: I
have a webform that shows a Crystal Report. In the page_init I export the
report to a pdf. When I hit the printbutton, the PDF shows. When I close the
form, the PDF is deleted from the server. So far, so good.

This works for all reports, exept for reports with parameters. The Crystal
Report shows in the browser, but the report is not exported to a pdf, with
the error that it is missing parameters. So, what I think is the case, is
that the parameters are forwarded to the viewer but not to the report
object. Can anybody help me out with this one?

I thought it would be something like this
myReport.DataDefinition.ParameterFields.Item("Peri ode").Value = ???

There is an extra catch in this, I am not using a discrete parameter but a
range parameter.
I have put the code here. The parameters are hardcoded in this case.

Please help!
Kind regards,
Alison.

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()
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions
Dim myParameterFieldDefinitions As ParameterFieldDefinitions
Dim myParameterFieldDefinition As ParameterFieldDefinition
Dim myExportFile As String
Dim myReport As New test

Dim myParameterFields As New ParameterFields
Dim myParameterField As New ParameterField
Dim myRangeValues As New ParameterRangeValue
Dim myRangeValue As New ParameterRangeValue
myParameterField.ParameterFieldName = "Periode"
myRangeValue.StartValue = 200409
myRangeValue.EndValue = 200510
myParameterField.CurrentValues.Add(myRangeValue)

myParameterFields.Add(myParameterField)
crvTest.ParameterFieldInfo = myParameterFields

myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
Session.SessionID.ToString & ".pdf"
myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
myDiskFileDestinationOptions.DiskFileName = myExportFile
myExportOptions = myReport.ExportOptions
With myExportOptions
.DestinationOptions = myDiskFileDestinationOptions
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = .ExportFormatType.PortableDocFormat

End With

Try
myReport.Export()
Catch err As Exception
Response.Write("<BR>")
Response.Write(err.Message.ToString)
End Try

Session("exportbestand") = myExportFile
crvTest.ReportSource = myReport

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)
Response.WriteFile(myExportFile)
Response.Flush()
Response.Close()

System.IO.File.Delete(myExportFile)
End Sub
Nov 23 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.