Telerik Reporting Print Dialog Box

18 posts, 0 answers
  1. Muhammad
    Muhammad avatar
    87 posts
    Member since:
    Oct 2012

    Posted 28 Jan 2011 Link to this post

    Hi,

    I would like to purchase telerik controls for my company but I will buy this product if you can provide me solution of below these problems because we are happy to buy this product.

    Problem 1:  I am using report Viewer for printing but every time when I click a button it shows a print dialog box which is very annoying sometimes. Is there anyway that I can set a default printer for that print button one time only.

    Problem 2:  I want to tell you that I have tried this method for directly send the job to the printer but it works fine in my development machine and the job goes directly to the printer but when I deployed the same code in the server the page never comes back.

            Dim printerSettings As New System.Drawing.Printing.PrinterSettings

            Dim standardPrintController As New System.Drawing.Printing.StandardPrintController        
            Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor
            reportProcessor.PrintController = standardPrintController
            reportProcessor.PrintReport(o, PrinterSettings)






  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 02 Feb 2011 Link to this post

    Hello Muhammad,

    Printing from the ReportViewer will always show the Print dialog and this behavior is not configurable. That is why we would suggest you another approach for printing a document without using the ReportViewer control.

    To implement the suggested approach you should have 2 pages: MainForm.aspx from which the request will be triggered and PrintForm.aspx which will serve the print report. Here is the concrete implementation of both pages:

    MainForm.aspx:
    Copy Code
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MainForm.aspx.cs" Inherits="MainForm" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function PrintReport() {
                var printFrame = document.getElementById("PrintFrame");
                printFrame.src = "PrintForm.aspx?tmp=" + new Date().getTime();
            }
      </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <iframe id="PrintFrame" src="javascript:'';" style="visibility:hidden;" width="1px" height="1px"></iframe>
            <asp:Button ID="Button1" Text="PrintReport" runat="server" Height="20px" OnClientClick="PrintReport(); return false;" />
            <br />
        </div>
        </form>
    </body>
    </html>

    PrintForms.aspx.cs:
    Copy Code
    public partial class PrintForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Hashtable deviceInfo = new Hashtable();
            deviceInfo["JavaScript"] = "this.print({bUI: false, bSilent: true, bShrinkToFit: true});";
     
            ReportProcessor reportProcessor = new ReportProcessor();
            RenderingResult result = reportProcessor.RenderReport("PDF", new BarcodesReport(), deviceInfo);
     
            string fileName = result.DocumentName + ".pdf";
     
            Response.Clear();
            Response.ContentType = result.MimeType;
            Response.Cache.SetCacheability(HttpCacheability.Private);
            Response.Expires = -1;
            Response.Buffer = true;
            Response.BinaryWrite(result.DocumentBytes);
            Response.End(); 
     
        }
    }

    The code is self-explanatory but if you have any questions about it, please let me know.

    Have in mind that printing silently is not somewhat advisory so the PDF plug-in will show a message that the document is trying to print although not displaying the Print dialog.

    Hope this helps.

    Best wishes,
    Steve
    the Telerik team
    Get started with Telerik Reporting with numerous videos and detailed documentation.
  3. DevCraft banner
  4. Muhammad
    Muhammad avatar
    87 posts
    Member since:
    Oct 2012

    Posted 22 Feb 2011 Link to this post

    Thank You so much ... this is what I really want ...
  5. Muhammad
    Muhammad avatar
    87 posts
    Member since:
    Oct 2012

    Posted 10 Mar 2011 Link to this post

    Last time you gave me a very positive reply and again I am expecting the same from you if you solve my problem regarding my question below.

    I am using Telerik Reporting for just printing in my windows service but what happen is that its showing a dialog box for printing and I am getting an exception. I have already defined a default printer name by my function. Any help would be greatly appreciated.

    Exception :

    Service cannot be started. System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

     System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
                printerSettings.PrinterName = GetDefaultPrinter();
                Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
                System.Drawing.Printing.StandardPrintController standardPrintController = new System.Drawing.Printing.StandardPrintController();
                Telerik.Reporting.Report rpt = new Telerik.Reporting.Report();            
                reportProcessor.PrintController = standardPrintController;
                reportProcessor.PrintReport(rpt, printerSettings); 



    public string GetDefaultPrinter()
            {
                System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
                foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
                {
                    printerSettings.PrinterName = printer;
                    if (printerSettings.IsDefaultPrinter)
                    {
                        return printerSettings.PrinterName;
                        //return printer;
                    }
                }
                return string.Empty;
            }
  6. john doe
    john  doe avatar
    11 posts
    Member since:
    Dec 2009

    Posted 16 Jun 2011 Link to this post

    Is there any solution found to this error message "Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application"

    I use telerik reporting and i am trying to print from console application (console application calls web service application which does the printing and exporting). 

    Printing and exporting PDF documents (through) Telerik works OK on my development machine but on production machine it throws exception at the line "reportProcessor.PrintReport(rpt, printerSettings);"

    Printer on the production machine is set as default printer.

    Is there any specific printer settings to be concerned of or maybe application executing Telerik printing must be "run as" on some higher administrative account or is this impossible to achieve by design? (it is odd though that on the development machine printing works ok)

    Thank you very much.

    Damir
  7. Vijetha
    Vijetha avatar
    9 posts
    Member since:
    Jul 2011

    Posted 24 Oct 2011 Link to this post

    Hi ,

    Even i got the same error message when  i am using ReportProcesor in my WCF service


    ErrorMsg:
    Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

    Below is my code

     Telerik.Reporting.Processing.ReportProcessor reportproc = new Telerik.Reporting.Processing.ReportProcessor();
                System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();
                reportproc.Error += new Telerik.Reporting.ErrorEventHandler(reportproc_Error);
           report1 obj =new report1();
                reportproc.PrintReport(obj , settings);

    This exactly works fine when i run the application on specific port(Use visual studio development server)
    Does not not work for IIS webserver.

    Please provide me the solution ASAp

    Thanks,
    vijetha

  8. Swetha
    Swetha avatar
    14 posts
    Member since:
    Apr 2013

    Posted 02 Jul 2013 Link to this post

    Hi Steve,

    i am gettig the below error
    Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application. 
    in my website when i print a report. It works fine in my development environment. Please suggest.
  9. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 05 Jul 2013 Link to this post

    Hello everyone,

    Using the ReportProcessor to print in in server-client environment will execute the print operation on the server side. Please use the suggested approach in the How to print report on client machine without showing the report help article.

    About the error you receive, you are trying to show a dialog box on the server. For more details check the discussion in the following msdn forum thread: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation.

    I hope this helps.

    Regards,
    Stef
    Telerik

    Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

  10. Support ATT
    Support ATT avatar
    66 posts
    Member since:
    Nov 2004

    Posted 15 Oct 2013 Link to this post

     
    Hello Stef 

     => Using the ReportProcessor to print in in server-client environment will execute the print operation on the server side.

    Yes, that is what i want, but without the Error caused PrintReport() Method. 

    I have a Webservice, who didn't work, with the same Error!

    private void printToDefaultPrinter(string aactionNumber)
        {
            int aactionNr = int.Parse(aactionNumber);
            aaction.Load_AactionNumber(aactionNr);
            ExceptionLog.Instance.addMessage2Log("AactionNumber: " + aactionNumber);
            ReportSettings reportSetting = new ReportSettings(aaction.CompanyId);
     
            report = getReportAlarm(aactionNr, reportSetting.reportPrint.PrintLanguage, aaction.CompanyId);
     
            PrinterSettings printerSettings = new PrinterSettings();
            printerSettings.PrinterName = GetDefaultPrinter();
            
            ReportProcessor reportProcessor = new ReportProcessor();
            reportProcessor.PrintController = new StandardPrintController();
     
            InstanceReportSource instanceReportSource = new InstanceReportSource();
            instanceReportSource.ReportDocument = report;
     
            ExceptionLog.Instance.addMessage2Log("Before PrintReport: " + aactionNumber);
            reportProcessor.PrintReport(instanceReportSource, printerSettings);
            ExceptionLog.Instance.addMessage2Log("After PrintReport: " + aactionNumber);
        }
     
        private string GetDefaultPrinter()
        {
            System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
            foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
            {
                printerSettings.PrinterName = printer;
                if (printerSettings.IsDefaultPrinter)
                {
                    return printerSettings.PrinterName;
                    //return printer;
                }
            }
            return string.Empty;
        }




  11. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 15 Oct 2013 Link to this post

    Hello,

    As previously explained showing modal dialogs on the server is not supported. When you host your application in IIS server it runs under specific user profile not having interaction with the desktop and thus showing popups as those from the print job results in the following exception:
    Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

    You can create a separate desktop application to print programmatically the desired report, otherwise please test the suggested client-side print options.

    Regards,
    Stef
    Telerik

    Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

  12. Support ATT
    Support ATT avatar
    66 posts
    Member since:
    Nov 2004

    Posted 16 Oct 2013 Link to this post

    Hi Stef,

    Possibly you didn't understand me. I need to print the report Document on serverside. Not on client side. Can you provide me a solution? I need to access the default Printer on the Server.
  13. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 16 Oct 2013 Link to this post

    Hello,

    Using ASP.NET and hosting the application in IIS would not allow you to perform the print operation on the server as required as the user under which is running the application does not have the required privileges to access the printer, causing the print dialog to be initialized.

    It is preferable to create a separate desktop application using the same report library and print the report from it.

    Regards,
    Stef
    Telerik

    Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

  14. Support ATT
    Support ATT avatar
    66 posts
    Member since:
    Nov 2004

    Posted 27 Dec 2013 Link to this post

    Hi Stef,


    You talking about to print it form a desktop Applikation. And yes, it work's well. 

    But it's is also possible to print it as background Service as Windows Service. Is there any Way with the report print library of Telerik. With an older version it had worked, but with the newest one, it's didn't work anymore like before.



    Thanks for your answer.

    David



  15. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 31 Dec 2013 Link to this post

    Hi David,

    You can print programmatically report definition using the ReportProcessor.PrintReport method. Please verify you have granted access to the printer and all required printer settings are set in order not to invoke the Print Dialog.

    If you need further help, please open a support ticket and send us the previously working project and details about the old and new used Telerik Reporting versions, including information about the applied access rules to allow the service to print  before the upgrade.

    Regards,
    Stef
    Telerik

    New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

  16. Support ATT
    Support ATT avatar
    66 posts
    Member since:
    Nov 2004

    Posted 06 Jan 2014 Link to this post

    Hi Stef


    Well, I have granted access to the Printer. Could you give me an Example as a Windows Service with all required settings which set in order to not invoke the Print Dialog.



    Thank you for your answer



    David



  17. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 08 Jan 2014 Link to this post

    Hi David,

    We have set the test project as follows:
    1. Implement a WCF Reporting service as illustrated in the How to: Self Host the Service
    2. Create a windows service that will open the Reporting service's ServiceHost on starting;
    3. Install the windows service and run it with your administrative credentials;
    4. To print without showing the Print dialog, use the approach described in the Hide the print progress dialog when printing a report programmatically help article - use a timer or directly print a report definition on start.

    Let us know if we miss any of your settings to replicate the issue.

    Regards,
    Stef
    Telerik

    New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

  18. Matthias
    Matthias avatar
    9 posts
    Member since:
    Feb 2011

    Posted 12 May 2015 in reply to Stef Link to this post

    Do you have an example? to use it as the WCF service seems not so clear to me...
  19. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 12 May 2015 Link to this post

    Hello Matthias,

    The attached demo project contains a standard Windows Service project, where on start we are printing a report as many times as specified on starting the service. The code uses standard print controller to get the default printer settings of the machine and print without additional confirmations - ReportProcessor.PrintReport Method.

    The project has an installer which operates with with the current user's account - ServiceProcessInstaller.Account Property(msdn). Thus the user must be an administrator of the machine to avoid any security popups on printing. The service is made to be started manually.

    Details how to install and start the service are available in How to: Install and Uninstall Services(msdn) and How to: Start Services(msdn). Note that most probably you will need administrator account to install and run the service. With the given demo you will be prompt to specify the user on installing the service.

    The accompanying video illustrates how to run it.

    Regards,
    Stef
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
DevCraft banner