How to print to matrix printer on the client with a web application?

I have an application made in c# MVC with a routine to print a simple text on the standard printer. The method RawPrinterHelper.SendStringToPrinter described in this Article was used. Printing normally occurs when I squeegee the application locally, but when I publish to the server, it lists the printers installed on the server and not on the client.

How do I get the application to take the printer from the client and not the server? If it is not possible, how do I open so the printers dialog by the application .NET C # MVC 4?

    public bool ImprimeConteudoDiretamenteNaImpressoraPadrao(string conteudo)
    {
       string nomeImpressoraPadrao = (new PrinterSettings()).PrinterName;
       return RawPrinterHelper.SendStringToPrinter(nomeImpressoraPadrao, conteudo);
    }
Author: Maniero, 2015-10-23

2 answers

Client is client, server is server. For reasons that should be obvious, it is not possible to access client resources through the server. The server can only send texts and other data for the browser to decide what to do.

Even in the client only the user can decide whether the printing will be carried out. A JavaScript code can start the process for the user to decide. You can't do more than this.

window.print();

Web applications are not solution for everything.

 5
Author: Maniero, 2015-10-23 20:48:40

I managed to solve my problem as follows. I installed the matrix printer drives on the web server and set the name of the printer installed directly in the application, in this way it worked without problems, the printer can be on the network or installed locally on the client.

string conteudo = "Teste impressão";
string _nomeImpressora = "EPSON FX-890 ESC/P";
RawPrinterHelper.SendStringToPrinter(_nomeImpressora, conteudo);
 0
Author: Luciano Mascarenhas, 2015-10-29 11:23:29