PDF export

A

Alison Givens

Hi all,

I am posting this question again, because I know that most readers only read
the new messages. I have been suffering with this problem for weeks now. I
tried several
newsgroups, but nobody can tell me how to solve this problem. And as it
seems, it will happen to me again in this newsgroup.
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("Periode").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
 

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

Top