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

Problem displaying as PDF

1 Answer 178 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andy Green
Top achievements
Rank 2
Andy Green asked on 27 Feb 2014, 10:22 AM
Hi

I'm having trouble getting the code example http://www.telerik.com/help/reporting/faq-display-pdf-browser.html


This line - Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", typeReportSource, Nothing)
throws the following error:

Value cannot be null.
Parameter name: type

Andy

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
 
    ExportToPDF("NoiseTestBlanks.trdx")
 
End Sub
 
Sub ExportToPDF(ByVal reportToExport As String)
 
    Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor()
    Dim typeReportSource As New Telerik.Reporting.TypeReportSource()
 
    ' reportToExport is the Assembly Qualified Name of the report
    typeReportSource.TypeName = reportToExport
 
    Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", typeReportSource, Nothing)
 
    Response.Clear()
    Response.ContentType = result.MimeType
    Response.Cache.SetCacheability(HttpCacheability.Private)
    Response.Expires = -1
    Response.Buffer = True
    'Uncomment to handle the file as attachment
    'Response.AddHeader("Content-Disposition", String.Format("{0};FileName=""{1}""", "attachment", reportToExport))
    Response.BinaryWrite(result.DocumentBytes)
    Response.End()
 
End Sub

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 03 Mar 2014, 04:00 PM
Hello Andy,

The used example is based on report definition created with Visual Studio. If you want to use a trdx (report definition created with the standalone Telerik Report Designer) you have to utilize UriReportSource as shown in the following updated code snippet. Just make sure that the report definition is available in the application bin or update the URI accordingly.
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
  
    ExportToPDF("NoiseTestBlanks.trdx")
  
End Sub
  
Sub ExportToPDF(ByVal reportToExport As String)
  
    Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor()
    Dim reportSource As New Telerik.Reporting.UriReportSource()
 
    reportSource.Uri= reportToExport
  
    Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", reportSource, Nothing)
  
    Response.Clear()
    Response.ContentType = result.MimeType
    Response.Cache.SetCacheability(HttpCacheability.Private)
    Response.Expires = -1
    Response.Buffer = True
    'Uncomment to handle the file as attachment
    'Response.AddHeader("Content-Disposition", String.Format("{0};FileName=""{1}""", "attachment", reportToExport))
    Response.BinaryWrite(result.DocumentBytes)
    Response.End()
  
End Sub

Regards,
Peter
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

Tags
General Discussions
Asked by
Andy Green
Top achievements
Rank 2
Answers by
Peter
Telerik team
Share this question
or