我挖掘了一个我在2006年提交的旧的codeproject文章,该文章从Crystal Reports项目导出为pdf。我不确定这些库是否已经相关 - 甚至更糟糕的是,它在VB中。希望这可以起作用,或者至少指向正确的方向。
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
'
' <snip>
Dim ExportToFile As New CsReports.Reports
ExportFile = ExportPath + Session.SessionID.ToString + ".pdf"
ExportToFile.ReportToPDF(crReportDocument, ExportFile)
Try
' Export the report
crReportDocument.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(ExportFile)
Response.Flush()
Response.Close()
System.IO.File.Delete(ExportFile)
Catch err As Exception
Throw err 'MessBox("Error: Export Failed.!" + err.Message.ToString)
End Try 'Adobe Acrobat Export***************************
然后有方法ReportToPDF:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System
Imports System.Data
Imports System.Web.UI.Page
Imports System.IO
Namespace CsReports
Public Class Reports
Inherits System.Web.UI.Page
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Public Sub ReportToPDF(ByVal crReportName As ReportDocument, ByVal ExportFile As String)
' Create a new instance of the diskfiledestinationoptions class and
' set variable called crExportOptions to the exportoptions class of the reportdocument.
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crExportOptions = crReportName.ExportOptions
'Set this file as the filename property for the DestinationOptions class
crDiskFileDestinationOptions.DiskFileName = ExportFile
'set the required report ExportOptions properties
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
End Sub
End Class
End Namespace
没有得到答案。当我们保存的PDF文件。它应该要求密码打开它...如何实现它。 – Niks 2013-04-05 05:26:35