tonelm54
asked on
ReportViewer render as PDF
Ive got a report working great using a ReportViewer in ASP.net, however every load I convert the HTML report into a PDF.
Is it possible instead of loading the ReportViewer up in the HTML view, outputting the PDF straight away?
I know I have to do:-
Response.ContentType = "application/pdf";
Response.AddHeader("conten t-disposit ion", "attachment; filename=Test.pdf)
However I have no idea how to set the ReportViewer to output PDF straight away.
Any ideas on how I can do this, any code examples would be appriciated.
Thank you
Is it possible instead of loading the ReportViewer up in the HTML view, outputting the PDF straight away?
I know I have to do:-
Response.ContentType = "application/pdf";
Response.AddHeader("conten
However I have no idea how to set the ReportViewer to output PDF straight away.
Any ideas on how I can do this, any code examples would be appriciated.
Thank you
ASKER
Looks good, but when it runs:-
b = ReportViewer1.LocalReport. Render("PD F", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
I get "An error occurred during local report processing."
b = ReportViewer1.LocalReport.
I get "An error occurred during local report processing."
ASKER
Without the code, it does render the HTML report correctly.
can you tell me more about the error? what exactly is the description?
ASKER
The message Im getting is:-
InnerException
Microsoft.ReportingService s.ReportPr ocessing.P rocessingA bortedExce ption: An error has occurred during report processing. ---> Microsoft.ReportingService s.ReportPr ocessing.R eportProce ssingExcep tion: DataSet1
Message
An error occurred during local report processing.
InnerException
Microsoft.ReportingService
Message
An error occurred during local report processing.
ASKER
My asp.net code is attached
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication18.WebForm1" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"
TypeName="WebApplication18.faultsdbDataSetTableAdapters.log_notesTableAdapter">
</asp:ObjectDataSource>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
<LocalReport ReportPath="Report1.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
</form>
</body>
</html>
'can you check please if DataSet1 is being set to rds as report datasource on Sub Page_LoadComplete
'it shoul be like this below
Dim rds As ReportDataSource = New ReportDataSource("DataSet1 ", ObjectDataSource1)
'it shoul be like this below
Dim rds As ReportDataSource = New ReportDataSource("DataSet1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
'''''''''''''''''''' try this one on your *.aspx.vb
''''''''''''''''''''''''''
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ReportViewer1.LocalReport.
End Sub
Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
Dim fl As String = "c:\inetpub\wwwroot\sample
Dim virtualDir = "http://localhost/samplereport.pdf"
Dim rds As ReportDataSource = New ReportDataSource("yourData
ReportViewer1.LocalReport.
ReportViewer1.LocalReport.
Dim b As Byte()
b = ReportViewer1.LocalReport.
If File.Exists(fl) = True Then
File.Delete(fl)
End If
Dim fs As New FileStream(fl, FileMode.Create)
fs.Write(b, 0, b.Length)
fs.Close()
If File.Exists(fl) = True Then
response.redirect(virtualD
'or use a httphandler instead of just redirecting
End If
End Sub