rpt.Document.Print Error

Posted by: ricgom731 on 18 April 2018, 11:55 am EST

    • Post Options:
    • Link

    Posted 18 April 2018, 11:55 am EST

    Good day.

    I have a MVC web application in which I want to print an Active Reports 11 report with the instruction.

    rpt.Document.Print (true, true, false);

    In development environment it works and it shows me the dialog box to print. But in production I get the next error.

    “Displaying a modal dialog box or a form when the application is not running in the UserInteractive mode is not a valid operation”

    Any solution?

  • Posted 19 April 2018, 5:51 am EST

    Hello,

    Thanks, you too!

    rpt.Document.Print (true, true, false) will always open the Print dialog on the server side. You cannot use this on the client side as it will print your document using whatever printer is attached to the server. You can export the report to Pdf format with “OnlyForPrint” option set to “true”. Please refer the following code:

    
      SectionReport1 rpt = new SectionReport1();
                rpt.Run();
                GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport pdfExport = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
                pdfExport.Options.OnlyForPrint = true;
                pdfExport.Export(rpt.Document, "PDF Path");
    
    

    Hope it helps.

    Thanks,

    Mohit

  • Posted 19 April 2018, 2:01 pm EST

    Thanks, but it does not help me for what I need. I need to print a report but without a previous view and I can print it only one time, and with the example that they sent me, it is to generate a pdf and then print it. But I also need the user to be able to print the report once, and I do it as the example that you sent me, by having the pdf you will be able to print it several times.

    If I use

    rpt.Document.Print (false, true, false);

    If I can directly print the report and in the event “private void Vt22rcencabe_PrintProgress (object sender, EventArgs e)” I can control sending to the database that this report was already printed so that next time they want to print it or because they are registered previous impression

    If I use

    rpt.Document.Print (false, true, false); I work well in development, that is, the report is printed if I saw it before, but when I upload it, production does not go out to the printer, do not print anything.

    For what is this? Any possible solution or idea?

  • Posted 20 April 2018, 7:20 am EST

    Hello Ricardo,

    Since you have an MVC web application, there is a level of security that prevents you from running code on the client’s machine. You cannot print directly to a printer on a client’s machine else it would be a security breach. The rpt.Document.Print() command would print the report on the server where your application is deployed and not on the client machine. Even the code to export to Pdf would export the pdf on the server. Are you looking to print the report on the server?

    Since, it is web application, I assume you would want to print the report on the client machine. For this, I would suggest you to load the Report in the WebViewer, but set the display property of the WebViewer to none, so it is not displayed on the screen. Next add an html button, call the WebViewer’s client side Print method in the button click and then remove/disable the button from the screen. This will allow the report to be printed only once. However, the user can choose to print the report to a Pdf using the ‘Microsoft Print to Pdf’ or Chrome’s Pdf extension, which cannot be controlled by the application.

    Hope this clarifies things for you. I have attached a sample MVC application for your reference. Please take a look.

    AR_MVC5_PrintOnce.zip

  • Posted 20 April 2018, 5:08 pm EST

    Thanks, but the example application gives me the following error.

    Excepción no controlada en línea 7, columna 2135 en http://localhost:52908/Home/GetReport?reportType=Section

    0x800a1391 - Error en tiempo de ejecución de JavaScript: ‘ViewerViewModel’ no está definido

  • Posted 23 April 2018, 2:42 am EST

    This error occurs when there is mismatch in the ActiveReports Reference and that mentioned in the web.config. Please follow these steps to resolve the error:

    1. Delete the bin and obj folders from the application
    2. Open the application in VS and delete the ActiveReports.ReportService.asmx from the application
    3. Right click on the project name in SolutionExplorer and select Add > New Item
    4. Select Visual C# in the left panel
    5. Select ActiveReports 12 Web Service and click Add. This will update the AR references to the version installed on your machine.
    6. Now you can re-build and run the application
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels