What is your question? Does it really not work?
Here is an example of what we did in 2005. We have defined the rptViewer1 control, which may or may not be visible to your needs. strFormat must contain "PDF" and strNomFicher the full path.
By the way, variable names and functions are in French, but it will still work :)
Public Sub CreerFichierRapport (ByVal strNomFichier As String, ByVal strFormat As String)
Dim bytes () As Byte
Dim strDeviceInfo As String = ""
Dim strMimeType As String = ""
Dim strEncoding As String = ""
Dim strExtension As String = ""
Dim strStreams () As String
Dim warnings () As Warning
Dim oFileStream As FileStream
_stream = New List (Of Stream)
Try
bytes = rptViewer1.LocalReport.Render (strFormat, strDeviceInfo, strMimeType, strEncoding, strExtension, strStreams, warnings)
oFileStream = New FileStream (strNomFichier, FileMode.Create)
oFileStream.Write (bytes, 0, bytes.Length)
_stream.Add (oFileStream)
Finally
If Not IsNothing (oFileStream) Then
oFileStream.Close ()
oFileStream.Dispose ()
End if
End try
End sub
source share