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