I have written a code which creates a pdf file exporting from Crystal Reports in VB.NET 2005. All the code is working fine and also PDF files are created ok, but I want to set a password to that PDF file programatically. Is there any solution?
Below is my code to create PDF files while exporting from Crystal Reports
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = "D:\PDFFiles\" & fileName
CrFormatTypeOptions.FirstPageNumber = 1 ' Start Page in the Report
CrFormatTypeOptions.LastPageNumber = 10 ' End Page in the Report
CrFormatTypeOptions.UsePageRange = True
CrExportOptions = CrReport.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
CrReport.Export()