Set printer settings in ReportViewer (WinForms)

7 posts, 1 answers
  1. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 23 Mar 2011 Link to this post

    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!
  2. Answer
    Ivan
    Admin
    Ivan avatar
    114 posts

    Posted 25 Mar 2011 Link to this post

    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
  3. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 30 Mar 2011 Link to this post

    This worked perfectly!  Thank you.
  4. Luis
    Luis avatar
    1 posts
    Member since:
    Oct 2012

    Posted 17 Oct 2012 Link to this post

    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,

  5. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 18 Oct 2012 Link to this post

    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!

  6. Muthuraj
    Muthuraj avatar
    5 posts
    Member since:
    Sep 2017

    Posted 06 Dec 2017 in reply to Ivan Link to this post

    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

  7. Muthuraj
    Muthuraj avatar
    5 posts
    Member since:
    Sep 2017

    Posted 06 Dec 2017 in reply to Muthuraj Link to this post

    Typo on above post.. it tooks approx 1.3Mins
Back to Top