derekr44
New member
I have a Crystal Report that exports itself as a pdf file and then redirects the users browser to the file exported. I would like to be able to have the pdf printing options to be preset (ie. landscape, legal paper, etc.) but I dont know how to do it. Here is the code I have so far:
Private Sub Export_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Export_Button.Click
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions
Dim myExportFile As String
Dim myReport As New LSPipeline()
myExportFile = "c:\inetpub\wwwroot\webapplication3\temp\" & 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
myReport.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.Redirect("http://dr-dp11-78c2/webapplication3/temp/" & Session.SessionID.ToString & ".pdf")
Response.Flush()
Response.Close()
System.IO.File.Delete(myExportFile)
End Sub
I know that is it possible to set the CrystalDecisions.Shared.ExportOptions.PrintOptions.PageOrientation to what I want it to be, but would that solve my problem? If it would, how would I include that in my code? Thanks for the help!
Private Sub Export_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Export_Button.Click
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions
Dim myExportFile As String
Dim myReport As New LSPipeline()
myExportFile = "c:\inetpub\wwwroot\webapplication3\temp\" & 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
myReport.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.Redirect("http://dr-dp11-78c2/webapplication3/temp/" & Session.SessionID.ToString & ".pdf")
Response.Flush()
Response.Close()
System.IO.File.Delete(myExportFile)
End Sub
I know that is it possible to set the CrystalDecisions.Shared.ExportOptions.PrintOptions.PageOrientation to what I want it to be, but would that solve my problem? If it would, how would I include that in my code? Thanks for the help!