我挖掘了一個我在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