rogdawg
rogdawg

Reputation: 687

Problem printing from ReportViewer control in ASP.NET web application

I have a web application that utilizes the ReportViewer control in ASP.NET. The reports are defined in the web application, in .rdlc files. The reports work great, except for the printing functionality. When the user clicks the "print" icon in the header section of the report, it appears that the web app tries to install SQL Server (?!). Here is the file download dialog that appears: alt text

Can anyone offer a guess as to what is going on? I am not sure where to even begin to debug this, cause this is all happening "behind the scenes" in the ReportViewer's code.

Thanks for any advice you can give.

Upvotes: 0

Views: 2352

Answers (2)

user1025145
user1025145

Reputation: 11

Yes. Before i was tried the same problem. But after that i got the solution. The main thing is, we cant print the report directly from the client machine. I have found two way to print the report in client machine. One is through the ActiveX control. The client dont know, how to install the ActiveX Control in their machine, mainly they dont want those irretating things. So i found the other way we can print through the PDF file. Now all are having adobe pdf reader in their machine. So i browsed, how to print directly pdf without saving in their client machine. Finally i got the solution. The steps are:

The sample code written in C#.

i). Convert Report to Memory Stream:

string reportType = "PDF";
    string mimeType;
    string encoding;
    string fileNameExtension;
    //The DeviceInfo settings should be changed based on the reportType
    ////http://msdn2.microsoft.com/en-us/library/ms155397.aspx 

    string deviceInfo = "<DeviceInfo>" + "  <OutputFormat>PDF</OutputFormat>" + "  <PageWidth>8.27in</PageWidth>" + "  <PageHeight>11.69in</PageHeight>" + "  <MarginTop>0in</MarginTop>" + "  <MarginLeft>0in</MarginLeft>" + "  <MarginRight>0in</MarginRight>" + "  <MarginBottom>0in</MarginBottom>" + "</DeviceInfo>";
    Warning[] warnings;
    string[] streams;
    byte[] renderedBytes;
    //Render the report       
    renderedBytes = _rptViewer.LocalReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
    Stream mystream = new MemoryStream(renderedBytes);

Upvotes: 1

Retired_User
Retired_User

Reputation: 1595

It's not SQL Server it's trying to install, its an activex/plugin to print report files, click yes, install this and try to print.

Upvotes: 2

Related Questions