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

3

I have an application made in C # MVC with a routine to print plain text on the default printer. The RawPrinterHelper.SendStringToPrinter method that is described in this article has been used. Printing normally occurs when I run the application locally, but when I publish to the server, it lists the printer installed on the server, not the client.

How do I get the application to get the printer from the client and not from the server? If it is not possible, how do I open the printer dialog box through the .Net C # MVC 4 application?

    public bool ImprimeConteudoDiretamenteNaImpressoraPadrao(string conteudo)
    {
       string nomeImpressoraPadrao = (new PrinterSettings()).PrinterName;
       return RawPrinterHelper.SendStringToPrinter(nomeImpressoraPadrao, conteudo);
    }
    
asked by anonymous 23.10.2015 / 22:43

2 answers

4

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

Even in the client only the user can decide if the impression will be made. A JavaScript code can start the process for the user to decide. You can not do more than this.

window.print();

Web applications are not the solution to everything.

    
23.10.2015 / 22:48
0

I was able to solve my problem as follows. I installed the dot matrix printer drivers on the web server and set the name of the installed printer directly in the application, so it worked without problems, the printer may 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);
    
29.10.2015 / 12:23