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

Set printer settings in ReportViewer (WinForms)

6 Answers 1995 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David A.
Top achievements
Rank 1
David A. asked on 23 Mar 2011, 09:48 PM
Hi,

I have an application where the user specifies # of copies, collation, etc. in their profile for different reports to save time when they print the report. When a user selects a report, I have them displaying in the ReportViewer.  Is it possible to define these print settings in the ReportViewer so when they click the print button it automatically uses these settings and prints the report with # of copies, collation, etc. already preconfigured?

Thanks!

6 Answers, 1 is accepted

Sort by
0
Accepted
Ivan
Telerik team
answered on 25 Mar 2011, 02:38 PM
Hi David A.,

To implement some custom printing logic you can handle the Print event of the ReportViewer component. Since this event supports cancellation you can disable the default printing logic of the viewer and replace it with your own implementation instead. For manual printing you can use the PrintReport method of the ReportProcessor class which allows you to pass the PrinterSettings as a parameter. Here is a small sample code snippet that demonstrates how to do this:

private void reportViewer_Print(object sender, CancelEventArgs eventArgs)
{
    eventArgs.Cancel = true;
  
    var printerSettings = new PrinterSettings();
  
    printerSettings.Copies = 3;
    printerSettings.Collate = true;
  
    var reportProcessor = new ReportProcessor();
  
    reportProcessor.PrintReport(this.reportViewer.Report, printerSettings);
}

I hope this is helpful enough to implement your custom printing. If you have some additional questions regarding this topic, please do not hesitate to ask.

Best wishes,
Ivan
the Telerik team
0
David A.
Top achievements
Rank 1
answered on 30 Mar 2011, 06:00 PM
This worked perfectly!  Thank you.
0
Luis
Top achievements
Rank 1
answered on 17 Oct 2012, 06:47 PM
It looks great for ReportViewerBase inside Telerik.ReportViewer.WinForms, but this event is not available for ReportViewer class inside Telerik.ReportViewer.Silverlight

My available event is just RenderBegin.Event

How can you use the same event? I'm facing the same problem, and I'm planning to use this solution.

Thanks,

0
Steve
Telerik team
answered on 18 Oct 2012, 07:55 AM
Hi Luis,

The event is suitable for the Windows Forms viewer as the printing occurs on the same machine which would print the reports. When you're using Silverlight, the viewer is on the client, while the reports are being printed on the server. There is no out of the box way to change the printersettings when printing from the Silverlight report viewer's print button, and if you need such functionality you should handle the printing yourself.

How to utilize our report service to retrieve the rendered report and invoke the Silverlight print API is elaborated in the following forum post.

Additionally you may find useful the System.Windows.Printing MSDN article.

Greetings,
Steve
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Muthuraj
Top achievements
Rank 2
answered on 06 Dec 2017, 03:52 PM

Hi Ivan,

I have facing an issue at the time print report called, The issue is delayed to excecute PrintReport as it is taking approx 1.3 secs which is huge time.

Could you please have a look on below code?

 public static bool Print(Telerik.Reporting.IReportDocument document, string printerName, short copies)
        {
            ReportProcessor processor = new ReportProcessor();

            System.Drawing.Printing.PrintController controller = new System.Drawing.Printing.StandardPrintController();

            processor.PrintController = controller;
            
            System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();

            printerSettings.PrinterName = printerName;
            printerSettings.Copies = copies;
            printerSettings.Collate = false;
var repSource = (Telerik.Reporting.InstanceReportSource)document.Reports.FirstOrDefault();

processor.PrintReport(repSource, printerSettings);

return true;
        }

 

Realy appreciate your inputs here and looking hear from you soon. Thanks!

 

Regards!

Muthu

0
Muthuraj
Top achievements
Rank 2
answered on 06 Dec 2017, 04:19 PM
Typo on above post.. it tooks approx 1.3Mins
Tags
General Discussions
Asked by
David A.
Top achievements
Rank 1
Answers by
Ivan
Telerik team
David A.
Top achievements
Rank 1
Luis
Top achievements
Rank 1
Steve
Telerik team
Muthuraj
Top achievements
Rank 2
Share this question
or