This is a migrated thread and some comments may be shown as answers.

Save/Upload direct from Export to PDF

1 Answer 256 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rodger
Top achievements
Rank 1
Rodger asked on 19 Mar 2008, 02:09 PM
Hi,

Programming in VB.

I am using Telerik reporting in our website development along with all your other asp.net controls and I need to programmatically produce a pdf file and the save it to a subdomain on the server.
I have used your code snippet (July 18, 2007) to produce the pdf and this works fine, but I would like to extend the code to save the pdf to a folder on a subdomain.

I notice a commented out line in the code

'WriteToFile(Server.MapPath("~\temp\" & fileName), reportBytes)


Perhaps this is what I am looking for, but I don't understand how to implement it.

Regards,

Andy.

1 Answer, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 20 Mar 2008, 03:17 PM
Hello Andy,

You can use the following code snippet to achieve the desired functionality:
Sub SaveToFile(ByVal report As Report, ByVal exportFormat As String, ByVal reportsLocation As String)
    Dim extension As String
    Dim mimeType As String
    Dim encoding As Encoding

    Dim reportBytes As Byte() = Telerik.Reporting.Processing.ReportProcessor.Render(exportFormat, report, Nothing, mimeType, extension, encoding)
    Dim reportName As String = IIf(String.IsNullOrEmpty(report.Name),report.[GetType]().Name,report.Name)
    reportName += "." + extension

    Using fs As New FileStream(reportsLocation + reportName, FileMode.Create)
        fs.Write(reportBytes, 0, reportBytes.Length)
    End Using
End Sub
For exampe:
        Dim report As Report = New ShapesReport()
        SaveToFile(report, "PDF", "C:\Reports\")

Hope this helps.

Sincerely yours,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Rodger
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Share this question
or