Print Report works locally but not when deployed to iis

1 Answer 695 Views
.NET 5 .NET Core General Discussions Programming Rendering Report Designer (standalone) Report Viewer - ASP.NET Report Viewer - MVC
Sofda
Top achievements
Rank 1
Sofda asked on 20 Dec 2021, 06:25 AM

Hi,

I have a problem when I  try to print report in controller. The thing is; it is working locally but when I deploy the project to iss I am getting error message says; "System.InvalidOperationException: No or invalid printer error on IIS server."


// Obtain the settings of the default printer
                System.Drawing.Printing.PrinterSettings printerSettings
                    = new System.Drawing.Printing.PrinterSettings();

                // The standard print controller comes with no UI
                System.Drawing.Printing.PrintController standardPrintController =
                    new System.Drawing.Printing.StandardPrintController();

                // Print the report using the custom print controller
                Telerik.Reporting.Processing.ReportProcessor reportProcessor
                    = new Telerik.Reporting.Processing.ReportProcessor();

                reportProcessor.PrintController = standardPrintController;

                    Telerik.Reporting.TypeReportSource typeReportSource =
                        new Telerik.Reporting.TypeReportSource();

                    //// reportName is the Assembly Qualified Name of the report
                    //typeReportSource.TypeName = reportName;

                // Create a new report source pointing to report definition
                var reportSource = new UriReportSource();
                reportSource.Uri = entity.ReportName;



                foreach (var i in entity.Parameters)
                {
                    reportSource.Parameters.Add(new Parameter(i.Key, i.Value));
                }


                    reportProcessor.PrintReport(reportSource, printerSettings);                    

                return null;

 

Please suggest,

Thanks

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 22 Dec 2021, 04:00 PM

Hello Arif,

The provided code is using the ReportProcessor class to print the report programmatically. Note that this printing happens server-side.

Generally, the PrintReport method sends the report rendered for printing to the printer spooler and leaves the rest to the latter. We use the System.Drawing.Printing Namespace functionality for this purpose. We delegate all the work for queueing and printing to this package.

Based on the error message, I suspect that the IIS server where the application is deployed cannot access any printer. Can you check this? You may also attach a Trace Listener to check whether our code will log more relevant information on the issue.

Regards,
Todor
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Tags
.NET 5 .NET Core General Discussions Programming Rendering Report Designer (standalone) Report Viewer - ASP.NET Report Viewer - MVC
Asked by
Sofda
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or